package com.gyc.game.cchess.model;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Administrator
 * 
 */
public class ChessBoardBitPlanes implements Cloneable {

	private static final byte Byte1 = (byte) 1;

	// _________66_67_68 ________
	// _________75 76 77 ________
	// _________84 85 86 ________
	public final static byte[] Pos_R_KING = { 66, 67, 68, 75, 76, 77, 84, 85,
			86 };

	// _________3___4__5 ________
	// _________12 13 14 ________
	// _________21 22 23 ________
	public final static byte[] Pos_B_KING = { 3, 4, 5, 12, 13, 14, 21, 22, 23 };

	public final static byte B_BISHOP = 5; // 黑士
	public final static byte B_CANON = 4; // 黑炮
	public final static byte B_CAR = 2; // 黑车
	public final static byte B_ELEPHANT = 6; // 黑象

	public final static byte B_HORSE = 3;// 黑马
	public final static byte B_KING = 1; // 黑帅 0001
	public final static byte B_PAWN = 7; // 黑卒 0111

	public final static byte B_BEGIN = B_KING;
	public final static byte B_END = B_PAWN;

	public final static byte color_black = 0;
	public final static byte color_red = 1;

	public final static byte NOCHESS = 0; // 没有棋子

	public final static byte R_BISHOP = 0x50;
	public final static byte R_CANON = 0x40;
	public final static byte R_CAR = 0x20;
	public final static byte R_ELEPHANT = 0x60;
	public final static byte R_HORSE = 0x30;
	public final static byte R_KING = 0x10;
	public final static byte R_PAWN = 0x70;

	public final static byte R_END = R_PAWN;
	public final static byte R_BEGIN = R_KING;

	public static int abs(int i) {
		return i > 0 ? i : -i;
	}

	public static boolean IsBlack(byte x) {
		// return (x & 0xF) > 0;
		return x < 8 & x > 0;
	}

	public static boolean IsRed(byte x) {
		// return (x & 0xF0) > 0;
		return x > 15;
	}

	public static boolean IsSameSide(byte x, byte y) {
		return ((x & 0xF) > 0 && (y & 0xF) > 0)
				|| ((x & 0xF0) > 0 && (y & 0xF0) > 0);
	}

	public static boolean IsValidMove(ChessBoardBitPlanes position, int rowF,
			int columnF, int rowT, int columnT) {

		int i = 0, j = 0;
		int nMoveChessID, nTargetID;

		if (rowF == rowT && columnF == columnT)
			return false;// 目的与源相同

		nMoveChessID = position.getXY(rowF, columnF);
		nTargetID = position.getXY(rowT, columnT);

		if (IsSameSide((byte) nMoveChessID, (byte) nTargetID))
			return false;// 不能吃自己的棋

		switch (nMoveChessID) {
		case B_KING:
			if (nTargetID == R_KING)// 老将见面?
			{
				if (columnF != columnT)
					return false;
				for (i = rowF + 1; i < rowT; i++)
					if (position.getXY(i, columnF) != NOCHESS)
						return false;
			} else {
				if (rowT > 2 || columnT > 5 || columnT < 3)
					return false;// 目标点在九宫之外
				if (abs(rowF - rowT) + abs(columnT - columnF) > 1)
					return false;// 将帅只走一步直线:
			}
			break;
		case R_BISHOP:

			if (rowT < 7 || columnT > 5 || columnT < 3)
				return false;// 士出九宫

			if (abs(rowF - rowT) != 1 || abs(columnT - columnF) != 1)
				return false; // 士走斜线

			break;

		case B_BISHOP: // 黑士

			if (rowT > 2 || columnT > 5 || columnT < 3)
				return false;// 士出九宫

			if (abs(rowF - rowT) != 1 || abs(columnT - columnF) != 1)
				return false; // 士走斜线

			break;

		case R_ELEPHANT:// 红象

			if (rowT < 5)
				return false;// 相不能过河

			if (abs(columnF - columnT) != 2 || abs(rowF - rowT) != 2)
				return false;// 相走田字

			if (position.getXY((rowF + rowT) / 2, (columnF + columnT) / 2) != NOCHESS)
				return false;// 相眼被塞住了

			break;

		case B_ELEPHANT:// 黑象

			if (rowT > 4)
				return false;// 相不能过河

			if (abs(columnF - columnT) != 2 || abs(rowF - rowT) != 2)
				return false;// 相走田字

			if (position.getXY((rowF + rowT) / 2, (columnF + columnT) / 2) != NOCHESS)
				return false;// 相眼被塞住了

			break;

		case B_PAWN: // 黑兵

			if (rowT < rowF)
				return false;// 兵不回头

			if (rowF < 5 && rowF == rowT)
				return false;// 兵过河前只能直走

			if (rowT - rowF + abs(columnT - columnF) > 1)
				return false;// 兵只走一步直线:

			break;

		case R_PAWN: // 红兵

			if (rowT > rowF)
				return false;// 兵不回头

			if (rowF > 4 && rowF == rowT)
				return false;// 兵过河前只能直走

			if (rowF - rowT + abs(columnT - columnF) > 1)
				return false;// 兵只走一步直线:

			break;

		case R_KING:
			if (nTargetID == B_KING)// 老将见面?
			{
				if (columnF != columnT)
					return false;// 两个将不在同一列
				for (i = rowF - 1; i > rowT; i--)
					if (position.getXY(i, columnF) != NOCHESS)
						return false;// 中间有别的子
			} else {
				if (rowT < 7 || columnT > 5 || columnT < 3)
					return false;// 目标点在九宫之外
				if (abs(rowF - rowT) + abs(columnT - columnF) > 1)
					return false;// 将帅只走一步直线:
			}
			break;

		case B_CAR:
		case R_CAR:

			if (rowF != rowT && columnF != columnT)
				return false; // 车走直线:

			if (rowF == rowT) {
				if (columnF < columnT) {
					for (i = columnF + 1; i < columnT; i++)
						if (position.getXY(rowF, i) != NOCHESS)
							return false;
				} else {
					for (i = columnT + 1; i < columnF; i++)
						if (position.getXY(rowF, i) != NOCHESS)
							return false;
				}
			} else {
				if (rowF < rowT) {
					for (j = rowF + 1; j < rowT; j++)
						if (position.getXY(j, columnF) != NOCHESS)
							return false;
				} else {
					for (j = rowT + 1; j < rowF; j++)
						if (position.getXY(j, columnF) != NOCHESS)
							return false;
				}
			}

			break;

		case B_HORSE:
		case R_HORSE:

			if (!((abs(columnT - columnF) == 1 && abs(rowT - rowF) == 2) || (abs(columnT
					- columnF) == 2 && abs(rowT - rowF) == 1)))
				return false;// 马走日字

			if (columnT - columnF == 2) {
				i = columnF + 1;
				j = rowF;
			} else if (columnF - columnT == 2) {
				i = columnF - 1;
				j = rowF;
			} else if (rowT - rowF == 2) {
				i = columnF;
				j = rowF + 1;
			} else if (rowF - rowT == 2) {
				i = columnF;
				j = rowF - 1;
			}

			if (position.getXY(j, i) != NOCHESS)
				return false;// 绊马腿

			break;

		case B_CANON:
		case R_CANON:

			if (rowF != rowT && columnF != columnT)
				return false; // 炮走直线:

			// 炮不吃子时经过的路线中不能有棋子

			if (position.getXY(rowT, columnT) == NOCHESS) {
				if (rowF == rowT) {
					if (columnF < columnT) {
						for (i = columnF + 1; i < columnT; i++)
							if (position.getXY(rowF, i) != NOCHESS)
								return false;
					} else {
						for (i = columnT + 1; i < columnF; i++)
							if (position.getXY(rowF, i) != NOCHESS)
								return false;
					}
				} else {
					if (rowF < rowT) {
						for (j = rowF + 1; j < rowT; j++)
							if (position.getXY(j, columnF) != NOCHESS)
								return false;
					} else {
						for (j = rowT + 1; j < rowF; j++)
							if (position.getXY(j, columnF) != NOCHESS)
								return false;
					}
				}
			}
			// 炮吃子时
			else {
				int count = 0;
				if (rowF == rowT) {
					if (columnF < columnT) {
						for (i = columnF + 1; i < columnT; i++)
							if (position.getXY(rowF, i) != NOCHESS)
								count++;
						if (count != 1)
							return false;
					} else {
						for (i = columnT + 1; i < columnF; i++)
							if (position.getXY(rowF, i) != NOCHESS)
								count++;
						if (count != 1)
							return false;
					}
				} else {
					if (rowF < rowT) {
						for (j = rowF + 1; j < rowT; j++)
							if (position.getXY(j, columnF) != NOCHESS)
								count++;
						if (count != 1)
							return false;
					} else {
						for (j = rowT + 1; j < rowF; j++)
							if (position.getXY(j, columnF) != NOCHESS)
								count++;
						if (count != 1)
							return false;
					}
				}
			}
			break;
		default:
			return false;
		}

		return true;
	}

	public BitPlane bp_all;
	
	ChessMove[][] m_MoveList;// 10*80

	byte r_king_pos;

	byte b_king_pos;

	public ChessMove lastMove;

	private List<ChessMove> movelist = new ArrayList<ChessMove>(200);

	int movepos = 0;

	private BitPlane bp_red_Jiang;

	private BitPlane bp_red_Shi;

	private BitPlane bp_red_Xiang;

	private BitPlane bp_red_Ma;

	private BitPlane bp_red_Ju;

	private BitPlane bp_red_Pao;

	private BitPlane bp_red_Zu;

	private BitPlane bp_black_Jiang;

	private BitPlane bp_black_Shi;

	private BitPlane bp_black_Xiang;

	private BitPlane bp_black_Ma;

	private BitPlane bp_black_Ju;

	private BitPlane bp_black_Pao;

	private BitPlane bp_black_Zu;

	// FIXME 替换成数组

	private Map<Byte, BitPlane> cibp = new HashMap<Byte, BitPlane>();

	public ChessBoardBitPlanes() {
		super();

		m_MoveList = new ChessMove[8][90];
		for (int i = 0; i < m_MoveList.length; i++) {
			ChessMove[] x = m_MoveList[i];
			for (int j = 0; j < x.length; j++) {
				x[j] = new ChessMove();
			}
		}

		bp_all = new BitPlane();

		bp_red_Jiang = new BitPlane();
		bp_red_Jiang.setXY((byte) 9, (byte) 4, (byte) 1);
		bp_all.setXY((byte) 9, (byte) 4, R_KING);
		r_king_pos = 85;
		bp_red_Jiang.setChessId(R_KING);
		cibp.put(R_KING, bp_red_Jiang);

		bp_red_Shi = new BitPlane();
		bp_red_Shi.setXY((byte) 9, (byte) 3, (byte) 1);
		bp_red_Shi.setXY((byte) 9, (byte) 5, (byte) 1);
		bp_all.setXY((byte) 9, (byte) 3, R_BISHOP);
		bp_all.setXY((byte) 9, (byte) 5, R_BISHOP);
		bp_red_Shi.setChessId(R_BISHOP);
		cibp.put(R_BISHOP, bp_red_Shi);

		bp_red_Xiang = new BitPlane();
		bp_red_Xiang.setXY((byte) 9, (byte) 2, (byte) 1);
		bp_red_Xiang.setXY((byte) 9, (byte) 6, (byte) 1);
		bp_all.setXY((byte) 9, (byte) 2, R_ELEPHANT);
		bp_all.setXY((byte) 9, (byte) 6, R_ELEPHANT);
		bp_red_Xiang.setChessId(R_ELEPHANT);
		cibp.put(R_ELEPHANT, bp_red_Xiang);

		bp_red_Ma = new BitPlane();
		bp_red_Ma.setXY((byte) 9, (byte) 1, (byte) 1);
		bp_red_Ma.setXY((byte) 9, (byte) 7, (byte) 1);
		bp_all.setXY((byte) 9, (byte) 1, R_HORSE);
		bp_all.setXY((byte) 9, (byte) 7, R_HORSE);
		bp_red_Ma.setChessId(R_HORSE);
		cibp.put(R_HORSE, bp_red_Ma);

		bp_red_Ju = new BitPlane();
		bp_red_Ju.setXY((byte) 9, (byte) 0, (byte) 1);
		bp_red_Ju.setXY((byte) 9, (byte) 8, (byte) 1);
		bp_all.setXY((byte) 9, (byte) 0, R_CAR);
		bp_all.setXY((byte) 9, (byte) 8, R_CAR);
		bp_red_Ju.setChessId(R_CAR);
		// /////////////////////////////////////
		cibp.put(R_CAR, bp_red_Ju);

		bp_red_Pao = new BitPlane();
		bp_red_Pao.setXY((byte) 7, (byte) 1, (byte) 1);
		bp_red_Pao.setXY((byte) 7, (byte) 7, (byte) 1);
		bp_all.setXY((byte) 7, (byte) 1, R_CANON);
		bp_all.setXY((byte) 7, (byte) 7, R_CANON);
		bp_red_Pao.setChessId(R_CANON);
		cibp.put(R_CANON, bp_red_Pao);

		bp_red_Zu = new BitPlane();
		bp_red_Zu.setXY((byte) 6, (byte) 0, (byte) 1);
		bp_red_Zu.setXY((byte) 6, (byte) 2, (byte) 1);
		bp_red_Zu.setXY((byte) 6, (byte) 4, (byte) 1);
		bp_red_Zu.setXY((byte) 6, (byte) 6, (byte) 1);
		bp_red_Zu.setXY((byte) 6, (byte) 8, (byte) 1);
		bp_all.setXY((byte) 6, (byte) 0, R_PAWN);
		bp_all.setXY((byte) 6, (byte) 2, R_PAWN);
		bp_all.setXY((byte) 6, (byte) 4, R_PAWN);
		bp_all.setXY((byte) 6, (byte) 6, R_PAWN);
		bp_all.setXY((byte) 6, (byte) 8, R_PAWN);
		bp_red_Zu.setChessId(R_PAWN);
		cibp.put(R_PAWN, bp_red_Zu);

		bp_black_Jiang = new BitPlane();
		bp_black_Jiang.setXY((byte) 0, (byte) 4, (byte) 1);
		bp_all.setXY((byte) 0, (byte) 4, B_KING);
		b_king_pos = 4;
		bp_black_Jiang.setChessId(B_KING);
		cibp.put(B_KING, bp_black_Jiang);

		bp_black_Shi = new BitPlane();
		bp_black_Shi.setXY((byte) 0, (byte) 3, (byte) 1);
		bp_black_Shi.setXY((byte) 0, (byte) 5, (byte) 1);
		bp_all.setXY((byte) 0, (byte) 3, B_BISHOP);
		bp_all.setXY((byte) 0, (byte) 5, B_BISHOP);
		bp_black_Shi.setChessId(B_BISHOP);
		cibp.put(B_BISHOP, bp_black_Shi);

		bp_black_Xiang = new BitPlane();
		bp_black_Xiang.setXY((byte) 0, (byte) 2, (byte) 1);
		bp_black_Xiang.setXY((byte) 0, (byte) 6, (byte) 1);
		bp_all.setXY((byte) 0, (byte) 2, B_ELEPHANT);
		bp_all.setXY((byte) 0, (byte) 6, B_ELEPHANT);
		bp_black_Xiang.setChessId(B_ELEPHANT);
		cibp.put(B_ELEPHANT, bp_black_Xiang);

		bp_black_Ma = new BitPlane();
		bp_black_Ma.setXY((byte) 0, (byte) 1, (byte) 1);
		bp_black_Ma.setXY((byte) 0, (byte) 7, (byte) 1);
		bp_all.setXY((byte) 0, (byte) 1, B_HORSE);
		bp_all.setXY((byte) 0, (byte) 7, B_HORSE);
		bp_black_Ma.setChessId(B_HORSE);
		cibp.put(B_HORSE, bp_black_Ma);

		bp_black_Ju = new BitPlane();
		bp_black_Ju.setXY((byte) 0, (byte) 0, (byte) 1);
		bp_black_Ju.setXY((byte) 0, (byte) 8, (byte) 1);
		bp_all.setXY((byte) 0, (byte) 0, B_CAR);
		bp_all.setXY((byte) 0, (byte) 8, B_CAR);
		bp_black_Ju.setChessId(B_CAR);
		cibp.put(B_CAR, bp_black_Ju);

		bp_black_Pao = new BitPlane();
		bp_black_Pao.setXY((byte) 2, (byte) 1, (byte) 1);
		bp_black_Pao.setXY((byte) 2, (byte) 7, (byte) 1);
		bp_all.setXY((byte) 2, (byte) 1, B_CANON);
		bp_all.setXY((byte) 2, (byte) 7, B_CANON);
		bp_black_Pao.setChessId(B_CANON);
		cibp.put(B_CANON, bp_black_Pao);

		bp_black_Zu = new BitPlane();
		bp_black_Zu.setXY((byte) 3, (byte) 0, (byte) 1);
		bp_black_Zu.setXY((byte) 3, (byte) 2, (byte) 1);
		bp_black_Zu.setXY((byte) 3, (byte) 4, (byte) 1);
		bp_black_Zu.setXY((byte) 3, (byte) 6, (byte) 1);
		bp_black_Zu.setXY((byte) 3, (byte) 8, (byte) 1);
		bp_all.setXY((byte) 3, (byte) 0, B_PAWN);
		bp_all.setXY((byte) 3, (byte) 2, B_PAWN);
		bp_all.setXY((byte) 3, (byte) 4, B_PAWN);
		bp_all.setXY((byte) 3, (byte) 6, B_PAWN);
		bp_all.setXY((byte) 3, (byte) 8, B_PAWN);

		cibp.put(B_PAWN, bp_black_Zu);

	}

	private void addB_ElephantMove4Pos(byte rowcolumn, final int txy, int depth) {
		ChessMove move = this.m_MoveList[depth][movepos];

		move.fChessId = B_ELEPHANT;
		move.fRowColumn = rowcolumn;
		move.tChessId = bp_all.getXY(txy);
		move.tRowColumn = (byte) txy;

		movepos++;

	}

	private void addB_ElephantMove4Pos4Chk(byte rowcolumn, int txy, int depth) {

		ChessMove move = this.m_MoveList[depth][movepos];
		move.fChessId = B_ELEPHANT;
		move.fRowColumn = rowcolumn;
		move.tChessId = bp_all.getXY(txy);
		move.tRowColumn = (byte) txy;

		this.makeMove(move);
		if (!this.isBlackKingAttacked()) {
			movepos++;
		}
		this.unMakeMove(move);

	}

	private void addB_KingMoveForTPos(int txy, byte rowcolumn, byte chessId,
			int depth) {
		final byte tchess = bp_all.getXY(txy);
		if (!IsBlack(tchess)) {
			ChessMove move = this.m_MoveList[depth][movepos];
			movepos++;
			move.fChessId = chessId;
			move.fRowColumn = rowcolumn;
			move.tChessId = tchess;
			move.tRowColumn = (byte) txy;
		}
	}

	private void addB_KingMoveForTPos4Chk(int txy, byte rowcolumn,
			byte chessId, int depth) {
		final byte tchess = bp_all.getXY(txy);
		if (!IsBlack(tchess)) {
			ChessMove move = this.m_MoveList[depth][movepos];

			move.fChessId = chessId;
			move.fRowColumn = rowcolumn;
			move.tChessId = tchess;
			move.tRowColumn = (byte) txy;

			this.makeMove(move);
			if (!this.isBlackKingAttacked()) {
				movepos++;
			}
			this.unMakeMove(move);
		}

	}

	/**
	 * 黑仕
	 * 
	 * 车马象仕将仕象马车 0 1 2 3 4 5 6 7 8
	 * 
	 * 
	 * @param movelist
	 * @param rowcolumn
	 * @param chessId
	 */
	private void addMove4B_BISHOP(byte rowcolumn, byte chessId, int depth) {

		byte chessOther;
		if (rowcolumn == 3 || rowcolumn == 5 || rowcolumn == 21
				|| rowcolumn == 23) {
			chessOther = bp_all.getXY(13);
			if (!IsBlack(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 13;

			}
		} else if (rowcolumn == 13) {
			chessOther = bp_all.getXY(3);
			if (!IsBlack(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 3;

			}

			chessOther = bp_all.getXY(5);
			if (!IsBlack(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 5;

			}
			chessOther = bp_all.getXY(21);
			if (!IsBlack(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 21;

			}
			chessOther = bp_all.getXY(23);
			if (!IsBlack(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 23;
			}

		}

	}

	private void addMove4B_BISHOP4Attacking(byte rowcolumn, byte chessId,
			int depth) {
		byte chessOther;
		if (rowcolumn == 3 || rowcolumn == 5 || rowcolumn == 21
				|| rowcolumn == 23) {
			chessOther = bp_all.getXY(13);
			if (IsRed(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 13;

			}
		} else if (rowcolumn == 13) {
			chessOther = bp_all.getXY(3);
			if (IsRed(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 3;

			}

			chessOther = bp_all.getXY(5);
			if (IsRed(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 5;

			}
			chessOther = bp_all.getXY(21);
			if (IsRed(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 21;

			}
			chessOther = bp_all.getXY(23);
			if (IsRed(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 23;
			}

		}
	}

	private void addMove4B_BISHOP4Chked(byte rowcolumn, byte chessId, int depth) {
		byte chessOther;
		if (rowcolumn == 3 || rowcolumn == 5 || rowcolumn == 21
				|| rowcolumn == 23) {
			chessOther = bp_all.getXY(13);
			if (!IsBlack(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 13;

				this.makeMove(move);
				if (!this.isBlackKingAttacked()) {
					movepos++;
				}
				this.unMakeMove(move);

			}
		} else if (rowcolumn == 13) {
			chessOther = bp_all.getXY(3);
			if (!IsBlack(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 3;
				this.makeMove(move);
				if (!this.isBlackKingAttacked()) {
					movepos++;
				}
				this.unMakeMove(move);

			}

			chessOther = bp_all.getXY(5);
			if (!IsBlack(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 5;

				this.makeMove(move);
				if (!this.isBlackKingAttacked()) {
					movepos++;
				}
				this.unMakeMove(move);

			}
			chessOther = bp_all.getXY(21);
			if (!IsBlack(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 21;
				this.makeMove(move);
				if (!this.isBlackKingAttacked()) {
					movepos++;
				}
				this.unMakeMove(move);

			}
			chessOther = bp_all.getXY(23);
			if (!IsBlack(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 23;
				this.makeMove(move);
				if (!this.isBlackKingAttacked()) {
					movepos++;
				}
				this.unMakeMove(move);

			}
		}

	}

	private void addMove4B_CANON(byte rowcolumn, byte chessId, int depth) {

		byte row = BitPlane.getRow(rowcolumn);
		// 行内 <-
		int rowcnt = 0;
		for (int i = rowcolumn - 1; i >= (row * BitPlane.width); i--) {
			final byte xy = bp_all.getXY(i);
			if (xy == 0 && rowcnt == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

			} else {
				if (xy != 0) {
					rowcnt++;
					if (rowcnt == 2) {
						if (!IsSameSide(chessId, xy)) {
							ChessMove move = this.m_MoveList[depth][movepos];
							movepos++;
							move.fChessId = chessId;
							move.fRowColumn = rowcolumn;
							move.tChessId = xy;
							move.tRowColumn = (byte) i;

						}
						break;
					}
				}
			}
		}

		// 行内 ->
		rowcnt = 0;
		for (int i = rowcolumn + 1; i <= (row * BitPlane.width + BitPlane.width - 1); i++) {
			final byte xy = bp_all.getXY(i);
			if (xy == 0 && rowcnt == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

			} else {
				if (xy != 0) {
					rowcnt++;
					if (rowcnt == 2) {
						if (!IsSameSide(chessId, xy)) {
							ChessMove move = this.m_MoveList[depth][movepos];
							movepos++;
							move.fChessId = chessId;
							move.fRowColumn = rowcolumn;
							move.tChessId = xy;
							move.tRowColumn = (byte) i;

						}
						break;
					}
				}
			}
		}

		// 列内 向上
		int columncnt = 0;
		for (int i = rowcolumn - BitPlane.width; i >= 0; i -= BitPlane.width) {
			final byte xy = bp_all.getXY(i);
			if (xy == 0 && columncnt == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

			} else {
				if (xy != 0) {
					columncnt++;
					if (columncnt == 2) {
						if (!IsSameSide(chessId, xy)) {
							ChessMove move = this.m_MoveList[depth][movepos];
							movepos++;
							move.fChessId = chessId;
							move.fRowColumn = rowcolumn;
							move.tChessId = xy;
							move.tRowColumn = (byte) i;

						}
						break;
					}
				}
			}
		}

		// 列内 向下
		columncnt = 0;
		for (int i = rowcolumn + BitPlane.width; i < BitPlane.height
				* BitPlane.width; i += BitPlane.width) {
			final byte xy = bp_all.getXY(i);

			if (xy == 0 && columncnt == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

			} else {
				if (xy != 0) {
					columncnt++;
					if (columncnt == 2) {
						if (!IsSameSide(chessId, xy)) {
							ChessMove move = this.m_MoveList[depth][movepos];
							movepos++;
							move.fChessId = chessId;
							move.fRowColumn = rowcolumn;
							move.tChessId = xy;
							move.tRowColumn = (byte) i;

						}
						break;
					}
				}

			}
		}
	}

	private void addMove4B_CANON4Attacking(byte rowcolumn, byte chessId,
			int depth) {
		byte row = BitPlane.getRow(rowcolumn);
		// 行内 <-
		int rowcnt = 0;
		for (int i = rowcolumn - 1; i >= (row * BitPlane.width); i--) {
			final byte xy = bp_all.getXY(i);
			if (xy == 0 && rowcnt == 0) {
			} else {
				if (xy != 0) {
					rowcnt++;
					if (rowcnt == 2) {
						if (IsRed(xy)) {
							ChessMove move = this.m_MoveList[depth][movepos];
							movepos++;
							move.fChessId = chessId;
							move.fRowColumn = rowcolumn;
							move.tChessId = xy;
							move.tRowColumn = (byte) i;

						}
						break;
					}
				}
			}
		}

		// 行内 ->
		rowcnt = 0;
		for (int i = rowcolumn + 1; i <= (row * BitPlane.width + BitPlane.width - 1); i++) {
			final byte xy = bp_all.getXY(i);
			if (xy == 0 && rowcnt == 0) {

			} else {
				if (xy != 0) {
					rowcnt++;
					if (rowcnt == 2) {
						if (IsRed(xy)) {
							ChessMove move = this.m_MoveList[depth][movepos];
							movepos++;
							move.fChessId = chessId;
							move.fRowColumn = rowcolumn;
							move.tChessId = xy;
							move.tRowColumn = (byte) i;

						}
						break;
					}
				}
			}
		}

		// 列内 向上
		int columncnt = 0;
		for (int i = rowcolumn - BitPlane.width; i >= 0; i -= BitPlane.width) {
			final byte xy = bp_all.getXY(i);
			if (xy == 0 && columncnt == 0) {

			} else {
				if (xy != 0) {
					columncnt++;
					if (columncnt == 2) {
						if (IsRed(xy)) {
							ChessMove move = this.m_MoveList[depth][movepos];
							movepos++;
							move.fChessId = chessId;
							move.fRowColumn = rowcolumn;
							move.tChessId = xy;
							move.tRowColumn = (byte) i;

						}
						break;
					}
				}
			}
		}

		// 列内 向下
		columncnt = 0;
		for (int i = rowcolumn + BitPlane.width; i < BitPlane.height
				* BitPlane.width; i += BitPlane.width) {
			final byte xy = bp_all.getXY(i);

			if (xy == 0 && columncnt == 0) {

			} else {
				if (xy != 0) {
					columncnt++;
					if (columncnt == 2) {
						if (IsRed(xy)) {
							ChessMove move = this.m_MoveList[depth][movepos];
							movepos++;
							move.fChessId = chessId;
							move.fRowColumn = rowcolumn;
							move.tChessId = xy;
							move.tRowColumn = (byte) i;

						}
						break;
					}
				}

			}
		}

	}

	private void addMove4B_CANON4Chked(byte rowcolumn, byte chessId, int depth) {
		byte row = BitPlane.getRow(rowcolumn);
		// 行内 <-
		int rowcnt = 0;
		for (int i = rowcolumn - 1; i >= (row * BitPlane.width); i--) {
			final byte xy = bp_all.getXY(i);
			if (xy == 0 && rowcnt == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

				this.makeMove(move);
				if (!this.isBlackKingAttacked()) {
					movepos++;
				}
				this.unMakeMove(move);

			} else {
				if (xy != 0) {
					rowcnt++;
					if (rowcnt == 2) {
						if (!IsSameSide(chessId, xy)) {
							ChessMove move = this.m_MoveList[depth][movepos];
							move.fChessId = chessId;
							move.fRowColumn = rowcolumn;
							move.tChessId = xy;
							move.tRowColumn = (byte) i;

							this.makeMove(move);
							if (!this.isBlackKingAttacked()) {
								movepos++;
							}
							this.unMakeMove(move);

						}
						break;
					}
				}
			}
		}

		// 行内 ->
		rowcnt = 0;
		for (int i = rowcolumn + 1; i <= (row * BitPlane.width + BitPlane.width - 1); i++) {
			final byte xy = bp_all.getXY(i);
			if (xy == 0 && rowcnt == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

				this.makeMove(move);
				if (!this.isBlackKingAttacked()) {
					movepos++;
				}
				this.unMakeMove(move);

			} else {
				if (xy != 0) {
					rowcnt++;
					if (rowcnt == 2) {
						if (!IsSameSide(chessId, xy)) {
							ChessMove move = this.m_MoveList[depth][movepos];
							move.fChessId = chessId;
							move.fRowColumn = rowcolumn;
							move.tChessId = xy;
							move.tRowColumn = (byte) i;

							this.makeMove(move);
							if (!this.isBlackKingAttacked()) {
								movepos++;
							}
							this.unMakeMove(move);

						}
						break;
					}
				}
			}
		}

		// 列内 向上
		int columncnt = 0;
		for (int i = rowcolumn - BitPlane.width; i >= 0; i -= BitPlane.width) {
			final byte xy = bp_all.getXY(i);
			if (xy == 0 && columncnt == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

				this.makeMove(move);
				if (!this.isBlackKingAttacked()) {
					movepos++;
				}
				this.unMakeMove(move);

			} else {
				if (xy != 0) {
					columncnt++;
					if (columncnt == 2) {
						if (!IsSameSide(chessId, xy)) {
							ChessMove move = this.m_MoveList[depth][movepos];

							move.fChessId = chessId;
							move.fRowColumn = rowcolumn;
							move.tChessId = xy;
							move.tRowColumn = (byte) i;

							this.makeMove(move);
							if (!this.isBlackKingAttacked()) {
								movepos++;
							}
							this.unMakeMove(move);

						}
						break;
					}
				}
			}
		}

		// 列内 向下
		columncnt = 0;
		for (int i = rowcolumn + BitPlane.width; i < BitPlane.height
				* BitPlane.width; i += BitPlane.width) {
			final byte xy = bp_all.getXY(i);

			if (xy == 0 && columncnt == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

				this.makeMove(move);
				if (!this.isBlackKingAttacked()) {
					movepos++;
				}
				this.unMakeMove(move);

			} else {
				if (xy != 0) {
					columncnt++;
					if (columncnt == 2) {
						if (!IsSameSide(chessId, xy)) {
							ChessMove move = this.m_MoveList[depth][movepos];

							move.fChessId = chessId;
							move.fRowColumn = rowcolumn;
							move.tChessId = xy;
							move.tRowColumn = (byte) i;

							this.makeMove(move);
							if (!this.isBlackKingAttacked()) {
								movepos++;
							}
							this.unMakeMove(move);

						}
						break;
					}
				}

			}
		}

	}

	private void addMove4B_CAR(byte rowcolumn, byte chessId, int depth) {
		byte row = BitPlane.getRow(rowcolumn);

		// byte column = BitPlane.getColumn(rowcolumn);
		// 行内 <-
		for (int i = rowcolumn - 1; i >= (row * BitPlane.width); i--) {
			if (bp_all.getXY(i) == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

			} else {
				// TODO 替换为 检查 target chessid
				if (IsRed(bp_all.getXY(i))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(i);
					move.tRowColumn = (byte) i;

				}
				break;
			}
		}

		// 行内 ->
		for (int i = rowcolumn + 1; i <= (row * BitPlane.width + BitPlane.width - 1); i++) {
			if (bp_all.getXY(i) == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

			} else {
				if (IsRed(bp_all.getXY(i))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(i);
					move.tRowColumn = (byte) i;

				}
				break;
			}
		}

		// 列内 向上
		for (int i = rowcolumn - BitPlane.width; i >= 0; i -= BitPlane.width) {
			if (bp_all.getXY(i) == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

			} else {
				if (IsRed(bp_all.getXY(i))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(i);
					move.tRowColumn = (byte) i;

				}
				break;
			}
		}

		// 列内 向下
		for (int i = rowcolumn + BitPlane.width; i < BitPlane.height
				* BitPlane.width; i += BitPlane.width) {
			if (bp_all.getXY(i) == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

			} else {
				if (IsRed(bp_all.getXY(i))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(i);
					move.tRowColumn = (byte) i;

				}
				break;
			}
		}

	}

	private void addMove4B_CAR4Attacking(byte rowcolumn, byte chessId, int depth) {

		byte row = BitPlane.getRow(rowcolumn);
		// byte column = BitPlane.getColumn(rowcolumn);
		// 行内 <-
		for (int i = rowcolumn - 1; i >= (row * BitPlane.width); i--) {
			final byte txy = bp_all.getXY(i);
			if (txy != 0) {
				if (IsRed(txy)) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = txy;
					move.tRowColumn = (byte) i;

				}
				break;
			}
		}

		// 行内 ->
		for (int i = rowcolumn + 1; i <= (row * BitPlane.width + BitPlane.width - 1); i++) {
			final byte txy = bp_all.getXY(i);
			if (txy != 0) {
				if (IsRed(txy)) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = txy;
					move.tRowColumn = (byte) i;

				}
				break;
			}
		}

		// 列内 向上
		for (int i = rowcolumn - BitPlane.width; i >= 0; i -= BitPlane.width) {
			final byte txy = bp_all.getXY(i);
			if (txy != 0) {
				if (IsRed(txy)) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = txy;
					move.tRowColumn = (byte) i;

				}
				break;
			}
		}

		// 列内 向下
		for (int i = rowcolumn + BitPlane.width; i < BitPlane.height
				* BitPlane.width; i += BitPlane.width) {
			final byte txy = bp_all.getXY(i);
			if (txy != 0) {
				if (IsRed(txy)) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = txy;
					move.tRowColumn = (byte) i;

				}
				break;
			}
		}

	}

	private void addMove4B_CAR4Chked(byte rowcolumn, byte chessId, int depth) {
		byte row = BitPlane.getRow(rowcolumn);

		// byte column = BitPlane.getColumn(rowcolumn);
		// 行内 <-
		for (int i = rowcolumn - 1; i >= (row * BitPlane.width); i--) {
			if (bp_all.getXY(i) == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

				this.makeMove(move);
				if (!this.isBlackKingAttacked()) {
					movepos++;
				}
				this.unMakeMove(move);

			} else {
				// TODO 替换为 检查 target chessid
				if (IsRed(bp_all.getXY(i))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(i);
					move.tRowColumn = (byte) i;

					this.makeMove(move);
					if (!this.isBlackKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);

				}
				break;
			}
		}

		// 行内 ->
		for (int i = rowcolumn + 1; i <= (row * BitPlane.width + BitPlane.width - 1); i++) {
			if (bp_all.getXY(i) == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

				this.makeMove(move);
				if (!this.isBlackKingAttacked()) {
					movepos++;
				}
				this.unMakeMove(move);

			} else {
				if (IsRed(bp_all.getXY(i))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(i);
					move.tRowColumn = (byte) i;

					this.makeMove(move);
					if (!this.isBlackKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);

				}
				break;
			}
		}

		// 列内 向上
		for (int i = rowcolumn - BitPlane.width; i >= 0; i -= BitPlane.width) {
			if (bp_all.getXY(i) == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

				this.makeMove(move);
				if (!this.isBlackKingAttacked()) {
					movepos++;
				}
				this.unMakeMove(move);

			} else {
				if (IsRed(bp_all.getXY(i))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(i);
					move.tRowColumn = (byte) i;

					this.makeMove(move);
					if (!this.isBlackKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);

				}
				break;
			}
		}

		// 列内 向下
		for (int i = rowcolumn + BitPlane.width; i < BitPlane.height
				* BitPlane.width; i += BitPlane.width) {
			if (bp_all.getXY(i) == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

				this.makeMove(move);
				if (!this.isBlackKingAttacked()) {
					movepos++;
				}
				this.unMakeMove(move);

			} else {
				if (IsRed(bp_all.getXY(i))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(i);
					move.tRowColumn = (byte) i;

					this.makeMove(move);
					if (!this.isBlackKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);

				}
				break;
			}
		}

	}

	/**
	 * 黑象
	 * 
	 * 0 1 2 3 4 5 6 7 8
	 * 
	 * 
	 * @param movelist
	 * @param rowcolumn
	 * @param chessId
	 */
	private void addMove4B_ELEPHANT(byte rowcolumn, byte chessId, int depth) {
		// __2___6
		// 18 22 26
		// __38 42

		switch (rowcolumn) {
		case 42:
			if (bp_all.getXY(32) == NOCHESS) {
				final int txy = 22;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}
			if (bp_all.getXY(34) == NOCHESS) {
				final int txy = 26;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}

			break;
		case 26:
			if (bp_all.getXY(16) == NOCHESS) {
				final int txy = 6;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}
			if (bp_all.getXY(34) == NOCHESS) {
				final int txy = 42;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}

			break;
		case 38:
			if (bp_all.getXY(28) == NOCHESS) {
				final int txy = 18;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}
			if (bp_all.getXY(30) == NOCHESS) {
				final int txy = 22;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}

			break;

		case 18:
			if (bp_all.getXY(10) == NOCHESS) {
				final int txy = 2;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}
			if (bp_all.getXY(28) == NOCHESS) {
				final int txy = 38;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}
			break;
		case 22:
			if (bp_all.getXY(12) == NOCHESS) {
				final int txy = 2;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}
			if (bp_all.getXY(30) == NOCHESS) {
				final int txy = 38;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}
			if (bp_all.getXY(14) == NOCHESS) {
				final int txy = 6;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}
			if (bp_all.getXY(32) == NOCHESS) {
				final int txy = 42;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}

			break;

		case 2:
			if (bp_all.getXY(10) == NOCHESS) {
				final int txy = 18;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}
			if (bp_all.getXY(12) == NOCHESS) {
				final int txy = 22;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}
			break;
		case 6:
			if (bp_all.getXY(14) == NOCHESS) {
				final int txy = 22;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}
			if (bp_all.getXY(16) == NOCHESS) {
				final int txy = 26;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}
			break;

		default:
			break;
		}

	}

	private void addMove4B_ELEPHANT4Attacking(byte rowcolumn, byte chessId,
			int depth) {
		// __2___6
		// 18 22 26
		// __38 42
		//

		// IsRed

		switch (rowcolumn) {
		case 42:
			if (bp_all.getXY(32) == NOCHESS) {
				final int txy = 22;
				if (IsRed(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}
			if (bp_all.getXY(34) == NOCHESS) {
				final int txy = 26;
				if (IsRed(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}

			break;
		case 26:
			if (bp_all.getXY(16) == NOCHESS) {
				final int txy = 6;
				if (IsRed(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}
			if (bp_all.getXY(34) == NOCHESS) {
				final int txy = 42;
				if (IsRed(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}

			break;
		case 38:
			if (bp_all.getXY(28) == NOCHESS) {
				final int txy = 18;
				if (IsRed(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}
			if (bp_all.getXY(30) == NOCHESS) {
				final int txy = 22;
				if (IsRed(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}

			break;

		case 18:
			if (bp_all.getXY(10) == NOCHESS) {
				final int txy = 2;
				if (IsRed(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}
			if (bp_all.getXY(28) == NOCHESS) {
				final int txy = 38;
				if (IsRed(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}
			break;
		case 22:
			if (bp_all.getXY(12) == NOCHESS) {
				final int txy = 2;
				if (IsRed(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}
			if (bp_all.getXY(30) == NOCHESS) {
				final int txy = 38;
				if (IsRed(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}
			if (bp_all.getXY(14) == NOCHESS) {
				final int txy = 6;
				if (IsRed(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}
			if (bp_all.getXY(32) == NOCHESS) {
				final int txy = 42;
				if (IsRed(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}

			break;

		case 2:
			if (bp_all.getXY(10) == NOCHESS) {
				final int txy = 18;
				if (IsRed(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}
			if (bp_all.getXY(12) == NOCHESS) {
				final int txy = 22;
				if (IsRed(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}
			break;
		case 6:
			if (bp_all.getXY(14) == NOCHESS) {
				final int txy = 22;
				if (IsRed(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}
			if (bp_all.getXY(16) == NOCHESS) {
				final int txy = 26;
				if (IsRed(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos(rowcolumn, txy, depth);
				}
			}
			break;

		default:
			break;
		}

	}

	private void addMove4B_ELEPHANT4Chked(byte rowcolumn, byte chessId,
			int depth) {
		switch (rowcolumn) {
		case 42:
			if (bp_all.getXY(32) == NOCHESS) {
				final int txy = 22;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos4Chk(rowcolumn, txy, depth);
				}
			}
			if (bp_all.getXY(34) == NOCHESS) {
				final int txy = 26;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos4Chk(rowcolumn, txy, depth);
				}
			}

			break;
		case 26:
			if (bp_all.getXY(16) == NOCHESS) {
				final int txy = 6;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos4Chk(rowcolumn, txy, depth);
				}
			}
			if (bp_all.getXY(34) == NOCHESS) {
				final int txy = 42;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos4Chk(rowcolumn, txy, depth);
				}
			}

			break;
		case 38:
			if (bp_all.getXY(28) == NOCHESS) {
				final int txy = 18;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos4Chk(rowcolumn, txy, depth);
				}
			}
			if (bp_all.getXY(30) == NOCHESS) {
				final int txy = 22;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos4Chk(rowcolumn, txy, depth);
				}
			}

			break;

		case 18:
			if (bp_all.getXY(10) == NOCHESS) {
				final int txy = 2;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos4Chk(rowcolumn, txy, depth);
				}
			}
			if (bp_all.getXY(28) == NOCHESS) {
				final int txy = 38;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos4Chk(rowcolumn, txy, depth);
				}
			}
			break;
		case 22:
			if (bp_all.getXY(12) == NOCHESS) {
				final int txy = 2;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos4Chk(rowcolumn, txy, depth);
				}
			}
			if (bp_all.getXY(30) == NOCHESS) {
				final int txy = 38;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos4Chk(rowcolumn, txy, depth);
				}
			}
			if (bp_all.getXY(14) == NOCHESS) {
				final int txy = 6;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos4Chk(rowcolumn, txy, depth);
				}
			}
			if (bp_all.getXY(32) == NOCHESS) {
				final int txy = 42;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos4Chk(rowcolumn, txy, depth);
				}
			}

			break;

		case 2:
			if (bp_all.getXY(10) == NOCHESS) {
				final int txy = 18;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos4Chk(rowcolumn, txy, depth);
				}
			}
			if (bp_all.getXY(12) == NOCHESS) {
				final int txy = 22;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos4Chk(rowcolumn, txy, depth);
				}
			}
			break;
		case 6:
			if (bp_all.getXY(14) == NOCHESS) {
				final int txy = 22;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos4Chk(rowcolumn, txy, depth);
				}
			}
			if (bp_all.getXY(16) == NOCHESS) {
				final int txy = 26;
				if (!IsBlack(bp_all.getXY(txy))) {
					addB_ElephantMove4Pos4Chk(rowcolumn, txy, depth);
				}
			}
			break;

		default:
			break;
		}

	}

	private void addMove4B_HORSE(byte rowcolumn, byte chessId, int depth) {
		byte row = BitPlane.getRow(rowcolumn);
		byte column = BitPlane.getColumn(rowcolumn);

		byte target = -1;
		byte middle = -1;

		byte trow = (byte) (row - 2);
		byte tcolumn = (byte) (column - 1);
		if (trow >= 0 && tcolumn >= 0) {
			target = bp_all.getXY(trow, tcolumn);
			if (!IsBlack(target)) {
				middle = bp_all.getXY((byte) (row - 1), column);
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn - 2 * BitPlane.width - 1);

					movepos++;

				}
			}
		}

		trow = (byte) (row - 2);
		tcolumn = (byte) (column + 1);
		if (trow >= 0 && tcolumn < BitPlane.width) {
			target = bp_all.getXY(rowcolumn - 2 * BitPlane.width + 1);
			if (!IsBlack(target)) {
				middle = bp_all.getXY((byte) (row - 1), column);
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn - 2 * BitPlane.width + 1);
					movepos++;
				}
			}
		}

		trow = (byte) (row - 1);
		tcolumn = (byte) (column - 2);
		if (trow >= 0 && tcolumn >= 0) {
			target = bp_all.getXY(rowcolumn - BitPlane.width - 2);
			if (!IsBlack(target)) {
				middle = bp_all.getXY(row, (byte) (column - 1));
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn - BitPlane.width - 2);
					movepos++;
				}
			}
		}

		trow = (byte) (row - 1);
		tcolumn = (byte) (column + 2);
		if (trow >= 0 && tcolumn < BitPlane.width) {
			target = bp_all.getXY(rowcolumn - BitPlane.width + 2);
			if (!IsBlack(target)) {
				middle = bp_all.getXY(row, (byte) (column + 1));
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn - BitPlane.width + 2);
					movepos++;
				}
			}
		}

		trow = (byte) (row + 1);
		tcolumn = (byte) (column - 2);
		if (trow < BitPlane.height && tcolumn >= 0) {
			target = bp_all.getXY(rowcolumn + BitPlane.width - 2);
			if (!IsBlack(target)) {
				middle = bp_all.getXY(row, (byte) (column - 1));
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn + BitPlane.width - 2);
					movepos++;
				}
			}
		}

		trow = (byte) (row + 1);
		tcolumn = (byte) (column + 2);
		if (trow < BitPlane.height && tcolumn < BitPlane.width) {
			target = bp_all.getXY(rowcolumn + BitPlane.width + 2);
			if (!IsBlack(target)) {
				middle = bp_all.getXY(row, (byte) (column + 1));
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn + BitPlane.width + 2);
					movepos++;
				}
			}
		}

		trow = (byte) (row + 2);
		tcolumn = (byte) (column - 1);
		if (trow < BitPlane.height && tcolumn >= 0) {
			target = bp_all.getXY(rowcolumn + 2 * BitPlane.width - 1);
			if (!IsBlack(target)) {
				middle = bp_all.getXY((byte) (row + 1), column);
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn + 2 * BitPlane.width - 1);
					movepos++;
				}
			}
		}

		trow = (byte) (row + 2);
		tcolumn = (byte) (column + 1);
		if (trow < BitPlane.height && tcolumn < BitPlane.width) {
			target = bp_all.getXY(rowcolumn + 2 * BitPlane.width + 1);
			if (!IsBlack(target)) {
				middle = bp_all.getXY((byte) (row + 1), column);
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn + 2 * BitPlane.width + 1);
					movepos++;
				}
			}
		}
	}

	private void addMove4B_HORSE4Attacking(byte rowcolumn, byte chessId,
			int depth) {
		byte row = BitPlane.getRow(rowcolumn);
		byte column = BitPlane.getColumn(rowcolumn);

		byte target = -1;
		byte middle = -1;

		byte trow = (byte) (row - 2);
		byte tcolumn = (byte) (column - 1);
		if (trow >= 0 && tcolumn >= 0) {
			target = bp_all.getXY(trow, tcolumn);
			if (IsRed(target)) {
				middle = bp_all.getXY((byte) (row - 1), column);
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn - 2 * BitPlane.width - 1);

				}
			}
		}

		trow = (byte) (row - 2);
		tcolumn = (byte) (column + 1);
		if (trow >= 0 && tcolumn < BitPlane.width) {
			target = bp_all.getXY(rowcolumn - 2 * BitPlane.width + 1);
			if (IsRed(target)) {
				middle = bp_all.getXY((byte) (row - 1), column);
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn - 2 * BitPlane.width + 1);

				}
			}
		}

		trow = (byte) (row - 1);
		tcolumn = (byte) (column - 2);
		if (trow >= 0 && tcolumn >= 0) {
			target = bp_all.getXY(rowcolumn - BitPlane.width - 2);
			if (IsRed(target)) {
				middle = bp_all.getXY(row, (byte) (column - 1));
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn - BitPlane.width - 2);

				}
			}
		}

		trow = (byte) (row - 1);
		tcolumn = (byte) (column + 2);
		if (trow >= 0 && tcolumn < BitPlane.width) {
			target = bp_all.getXY(rowcolumn - BitPlane.width + 2);
			if (IsRed(target)) {
				middle = bp_all.getXY(row, (byte) (column + 1));
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn - BitPlane.width + 2);

				}
			}
		}

		trow = (byte) (row + 1);
		tcolumn = (byte) (column - 2);
		if (trow < BitPlane.height && tcolumn >= 0) {
			target = bp_all.getXY(rowcolumn + BitPlane.width - 2);
			if (IsRed(target)) {
				middle = bp_all.getXY(row, (byte) (column - 1));
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn + BitPlane.width - 2);

				}
			}
		}

		trow = (byte) (row + 1);
		tcolumn = (byte) (column + 2);
		if (trow < BitPlane.height && tcolumn < BitPlane.width) {
			target = bp_all.getXY(rowcolumn + BitPlane.width + 2);
			if (IsRed(target)) {
				middle = bp_all.getXY(row, (byte) (column + 1));
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn + BitPlane.width + 2);

				}
			}
		}

		trow = (byte) (row + 2);
		tcolumn = (byte) (column - 1);
		if (trow < BitPlane.height && tcolumn >= 0) {
			target = bp_all.getXY(rowcolumn + 2 * BitPlane.width - 1);
			if (IsRed(target)) {
				middle = bp_all.getXY((byte) (row + 1), column);
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn + 2 * BitPlane.width - 1);

				}
			}
		}

		trow = (byte) (row + 2);
		tcolumn = (byte) (column + 1);
		if (trow < BitPlane.height && tcolumn < BitPlane.width) {
			target = bp_all.getXY(rowcolumn + 2 * BitPlane.width + 1);
			if (IsRed(target)) {
				middle = bp_all.getXY((byte) (row + 1), column);
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn + 2 * BitPlane.width + 1);

				}
			}
		}

	}

	private void addMove4B_HORSE4Chked(byte rowcolumn, byte chessId, int depth) {
		byte row = BitPlane.getRow(rowcolumn);
		byte column = BitPlane.getColumn(rowcolumn);

		byte target = -1;
		byte middle = -1;

		byte trow = (byte) (row - 2);
		byte tcolumn = (byte) (column - 1);
		if (trow >= 0 && tcolumn >= 0) {
			target = bp_all.getXY(trow, tcolumn);
			if (!IsBlack(target)) {
				middle = bp_all.getXY((byte) (row - 1), column);
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn - 2 * BitPlane.width - 1);

					this.makeMove(move);
					if (!this.isBlackKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);

				}
			}
		}

		trow = (byte) (row - 2);
		tcolumn = (byte) (column + 1);
		if (trow >= 0 && tcolumn < BitPlane.width) {
			target = bp_all.getXY(rowcolumn - 2 * BitPlane.width + 1);
			if (!IsBlack(target)) {
				middle = bp_all.getXY((byte) (row - 1), column);
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn - 2 * BitPlane.width + 1);
					this.makeMove(move);
					if (!this.isBlackKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);
				}
			}
		}

		trow = (byte) (row - 1);
		tcolumn = (byte) (column - 2);
		if (trow >= 0 && tcolumn >= 0) {
			target = bp_all.getXY(rowcolumn - BitPlane.width - 2);
			if (!IsBlack(target)) {
				middle = bp_all.getXY(row, (byte) (column - 1));
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn - BitPlane.width - 2);
					this.makeMove(move);
					if (!this.isBlackKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);
				}
			}
		}

		trow = (byte) (row - 1);
		tcolumn = (byte) (column + 2);
		if (trow >= 0 && tcolumn < BitPlane.width) {
			target = bp_all.getXY(rowcolumn - BitPlane.width + 2);
			if (!IsBlack(target)) {
				middle = bp_all.getXY(row, (byte) (column + 1));
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn - BitPlane.width + 2);
					this.makeMove(move);
					if (!this.isBlackKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);
				}
			}
		}

		trow = (byte) (row + 1);
		tcolumn = (byte) (column - 2);
		if (trow < BitPlane.height && tcolumn >= 0) {
			target = bp_all.getXY(rowcolumn + BitPlane.width - 2);
			if (!IsBlack(target)) {
				middle = bp_all.getXY(row, (byte) (column - 1));
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn + BitPlane.width - 2);
					this.makeMove(move);
					if (!this.isBlackKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);
				}
			}
		}

		trow = (byte) (row + 1);
		tcolumn = (byte) (column + 2);
		if (trow < BitPlane.height && tcolumn < BitPlane.width) {
			target = bp_all.getXY(rowcolumn + BitPlane.width + 2);
			if (!IsBlack(target)) {
				middle = bp_all.getXY(row, (byte) (column + 1));
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn + BitPlane.width + 2);
					this.makeMove(move);
					if (!this.isBlackKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);
				}
			}
		}

		trow = (byte) (row + 2);
		tcolumn = (byte) (column - 1);
		if (trow < BitPlane.height && tcolumn >= 0) {
			target = bp_all.getXY(rowcolumn + 2 * BitPlane.width - 1);
			if (!IsBlack(target)) {
				middle = bp_all.getXY((byte) (row + 1), column);
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn + 2 * BitPlane.width - 1);
					this.makeMove(move);
					if (!this.isBlackKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);
				}
			}
		}

		trow = (byte) (row + 2);
		tcolumn = (byte) (column + 1);
		if (trow < BitPlane.height && tcolumn < BitPlane.width) {
			target = bp_all.getXY(rowcolumn + 2 * BitPlane.width + 1);
			if (!IsBlack(target)) {
				middle = bp_all.getXY((byte) (row + 1), column);
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn + 2 * BitPlane.width + 1);
					this.makeMove(move);
					if (!this.isBlackKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);
				}
			}
		}

	}

	// _________3___4__5 ________
	// _________12 13 14 ________
	// _________21 22 23 ________
	private void addMove4B_KING(byte rowcolumn, byte chessId, int depth) {

		// _________66_67_68 ________
		// _________75 76 77 ________
		// _________84 85 86 ________

		byte oxy = this.r_king_pos;
		byte[] p = ChessBoardBitPlanes.Pos_R_KING;
		for (int i = 0; i < p.length; i++) {
			byte pos = p[i];
			if (bp_all.getXY(pos) == R_KING) {
				oxy = pos;
				break;
			}
		}

		boolean block = false;

		if (oxy > -1) {
			if ((rowcolumn - oxy) % 9 == 0) {

				for (int i = oxy - 9; i > rowcolumn; i -= 9) {
					if (bp_all.getXY(i) != NOCHESS) {
						block = true;
						break;
					}
				}
				if (!block) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = R_KING;
					move.tRowColumn = (byte) oxy;

				}
			}
		}

		switch (rowcolumn) {
		case 3:
			addB_KingMoveForTPos(4, rowcolumn, chessId, depth);
			addB_KingMoveForTPos(12, rowcolumn, chessId, depth);
			break;
		case 4:
			addB_KingMoveForTPos(3, rowcolumn, chessId, depth);
			addB_KingMoveForTPos(5, rowcolumn, chessId, depth);
			addB_KingMoveForTPos(13, rowcolumn, chessId, depth);
			break;
		case 5:
			addB_KingMoveForTPos(4, rowcolumn, chessId, depth);
			addB_KingMoveForTPos(14, rowcolumn, chessId, depth);
			break;
		case 12:
			addB_KingMoveForTPos(3, rowcolumn, chessId, depth);
			addB_KingMoveForTPos(13, rowcolumn, chessId, depth);
			addB_KingMoveForTPos(21, rowcolumn, chessId, depth);
			break;
		case 13:
			addB_KingMoveForTPos(4, rowcolumn, chessId, depth);
			addB_KingMoveForTPos(12, rowcolumn, chessId, depth);
			addB_KingMoveForTPos(14, rowcolumn, chessId, depth);
			addB_KingMoveForTPos(22, rowcolumn, chessId, depth);
			break;
		case 14:
			addB_KingMoveForTPos(5, rowcolumn, chessId, depth);
			addB_KingMoveForTPos(13, rowcolumn, chessId, depth);
			addB_KingMoveForTPos(23, rowcolumn, chessId, depth);
			break;
		case 21:
			addB_KingMoveForTPos(12, rowcolumn, chessId, depth);
			addB_KingMoveForTPos(22, rowcolumn, chessId, depth);
			break;
		case 22:
			addB_KingMoveForTPos(13, rowcolumn, chessId, depth);
			addB_KingMoveForTPos(21, rowcolumn, chessId, depth);
			addB_KingMoveForTPos(23, rowcolumn, chessId, depth);
			break;
		case 23:
			addB_KingMoveForTPos(14, rowcolumn, chessId, depth);
			addB_KingMoveForTPos(22, rowcolumn, chessId, depth);
			break;
		default:
			break;
		}
	}

	private void addMove4B_KING4Chked(byte rowcolumn, byte chessId, int depth) {

		byte redxy = this.r_king_pos;
		byte redColumn = (byte) (redxy % 9);
		byte redRow = (byte) (redxy / 9);

		byte blackColumn = (byte) (rowcolumn % 9);
		byte blackRow = (byte) (rowcolumn / 9);

		final int cd = blackColumn - redColumn;

		if (cd == 1 || cd == -1) {
			boolean block = false;
			for (int row = redRow - 1; row > blackRow; row--) {
				if (this.getXY(row, redColumn) != NOCHESS) {
					block = true;
					break;
				}
			}
			if (block) {
				switch (rowcolumn) {
				case 3:
					addB_KingMoveForTPos4Chk(4, rowcolumn, chessId, depth);
					addB_KingMoveForTPos4Chk(12, rowcolumn, chessId, depth);
					break;
				case 4:
					addB_KingMoveForTPos4Chk(3, rowcolumn, chessId, depth);
					addB_KingMoveForTPos4Chk(5, rowcolumn, chessId, depth);
					addB_KingMoveForTPos4Chk(13, rowcolumn, chessId, depth);
					break;
				case 5:
					addB_KingMoveForTPos4Chk(4, rowcolumn, chessId, depth);
					addB_KingMoveForTPos4Chk(14, rowcolumn, chessId, depth);
					break;
				case 12:
					addB_KingMoveForTPos4Chk(3, rowcolumn, chessId, depth);
					addB_KingMoveForTPos4Chk(13, rowcolumn, chessId, depth);
					addB_KingMoveForTPos4Chk(21, rowcolumn, chessId, depth);
					break;
				case 13:
					addB_KingMoveForTPos4Chk(4, rowcolumn, chessId, depth);
					addB_KingMoveForTPos4Chk(12, rowcolumn, chessId, depth);
					addB_KingMoveForTPos4Chk(14, rowcolumn, chessId, depth);
					addB_KingMoveForTPos4Chk(22, rowcolumn, chessId, depth);
					break;
				case 14:
					addB_KingMoveForTPos4Chk(5, rowcolumn, chessId, depth);
					addB_KingMoveForTPos4Chk(13, rowcolumn, chessId, depth);
					addB_KingMoveForTPos4Chk(23, rowcolumn, chessId, depth);
					break;
				case 21:
					addB_KingMoveForTPos4Chk(12, rowcolumn, chessId, depth);
					addB_KingMoveForTPos4Chk(22, rowcolumn, chessId, depth);
					break;
				case 22:
					addB_KingMoveForTPos4Chk(13, rowcolumn, chessId, depth);
					addB_KingMoveForTPos4Chk(21, rowcolumn, chessId, depth);
					addB_KingMoveForTPos4Chk(23, rowcolumn, chessId, depth);
					break;
				case 23:
					addB_KingMoveForTPos4Chk(14, rowcolumn, chessId, depth);
					addB_KingMoveForTPos4Chk(22, rowcolumn, chessId, depth);
					break;
				default:
					break;
				}

			} else {// 对脸
				switch (rowcolumn) {
				case 3:
					addB_KingMoveForTPos4Chk(12, rowcolumn, chessId, depth);
					break;
				case 4:
					if (cd == 1) {
						addB_KingMoveForTPos4Chk(5, rowcolumn, chessId, depth);
					} else {
						addB_KingMoveForTPos4Chk(3, rowcolumn, chessId, depth);
					}
					addB_KingMoveForTPos4Chk(13, rowcolumn, chessId, depth);
					break;
				case 5:
					addB_KingMoveForTPos4Chk(14, rowcolumn, chessId, depth);
					break;
				case 12:
					addB_KingMoveForTPos4Chk(3, rowcolumn, chessId, depth);
					addB_KingMoveForTPos4Chk(21, rowcolumn, chessId, depth);
					break;
				case 13:
					addB_KingMoveForTPos4Chk(4, rowcolumn, chessId, depth);
					if (cd == 1) {
						addB_KingMoveForTPos4Chk(14, rowcolumn, chessId, depth);
					} else {
						addB_KingMoveForTPos4Chk(12, rowcolumn, chessId, depth);
					}

					addB_KingMoveForTPos4Chk(22, rowcolumn, chessId, depth);
					break;
				case 14:
					addB_KingMoveForTPos4Chk(5, rowcolumn, chessId, depth);

					addB_KingMoveForTPos4Chk(23, rowcolumn, chessId, depth);
					break;
				case 21:
					addB_KingMoveForTPos4Chk(12, rowcolumn, chessId, depth);
					break;
				case 22:
					addB_KingMoveForTPos4Chk(13, rowcolumn, chessId, depth);
					if (cd == 1) {
						addB_KingMoveForTPos4Chk(23, rowcolumn, chessId, depth);
					} else {
						addB_KingMoveForTPos4Chk(21, rowcolumn, chessId, depth);
					}
					break;
				case 23:
					addB_KingMoveForTPos4Chk(14, rowcolumn, chessId, depth);
					break;
				default:
					break;
				}

			}

		} else {
			switch (rowcolumn) {
			case 3:
				addB_KingMoveForTPos4Chk(4, rowcolumn, chessId, depth);
				addB_KingMoveForTPos4Chk(12, rowcolumn, chessId, depth);
				break;
			case 4:
				addB_KingMoveForTPos4Chk(3, rowcolumn, chessId, depth);
				addB_KingMoveForTPos4Chk(5, rowcolumn, chessId, depth);
				addB_KingMoveForTPos4Chk(13, rowcolumn, chessId, depth);
				break;
			case 5:
				addB_KingMoveForTPos4Chk(4, rowcolumn, chessId, depth);
				addB_KingMoveForTPos4Chk(14, rowcolumn, chessId, depth);
				break;
			case 12:
				addB_KingMoveForTPos4Chk(3, rowcolumn, chessId, depth);
				addB_KingMoveForTPos4Chk(13, rowcolumn, chessId, depth);
				addB_KingMoveForTPos4Chk(21, rowcolumn, chessId, depth);
				break;
			case 13:
				addB_KingMoveForTPos4Chk(4, rowcolumn, chessId, depth);
				addB_KingMoveForTPos4Chk(12, rowcolumn, chessId, depth);
				addB_KingMoveForTPos4Chk(14, rowcolumn, chessId, depth);
				addB_KingMoveForTPos4Chk(22, rowcolumn, chessId, depth);
				break;
			case 14:
				addB_KingMoveForTPos4Chk(5, rowcolumn, chessId, depth);
				addB_KingMoveForTPos4Chk(13, rowcolumn, chessId, depth);
				addB_KingMoveForTPos4Chk(23, rowcolumn, chessId, depth);
				break;
			case 21:
				addB_KingMoveForTPos4Chk(12, rowcolumn, chessId, depth);
				addB_KingMoveForTPos4Chk(22, rowcolumn, chessId, depth);
				break;
			case 22:
				addB_KingMoveForTPos4Chk(13, rowcolumn, chessId, depth);
				addB_KingMoveForTPos4Chk(21, rowcolumn, chessId, depth);
				addB_KingMoveForTPos4Chk(23, rowcolumn, chessId, depth);
				break;
			case 23:
				addB_KingMoveForTPos4Chk(14, rowcolumn, chessId, depth);
				addB_KingMoveForTPos4Chk(22, rowcolumn, chessId, depth);
				break;
			default:
				break;
			}
		}

	}

	private void addMove4B_KINGAttacking(byte rowcolumn, byte chessId, int depth) {
		// _________66_67_68 ________
		// _________75 76 77 ________
		// _________84 85 86 ________

		byte oxy = -1;
		byte[] p = ChessBoardBitPlanes.Pos_R_KING;
		for (int i = 0; i < p.length; i++) {
			byte pos = p[i];
			if (bp_all.getXY(pos) == R_KING) {
				oxy = pos;
				break;
			}
		}

		if (oxy > -1) {
			if ((rowcolumn - oxy) % 9 == 0) {
				boolean block = false;
				for (int i = oxy - 9; i > rowcolumn; i -= 9) {
					if (bp_all.getXY(i) != NOCHESS) {
						block = true;
						break;
					}
				}
				if (!block) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = R_KING;
					move.tRowColumn = (byte) oxy;

				}
			}
		}

		switch (rowcolumn) {
		case 3:
			if (IsRed(bp_all.getXY(4)))
				addB_KingMoveForTPos(4, rowcolumn, chessId, depth);
			if (IsRed(bp_all.getXY(12)))
				addB_KingMoveForTPos(12, rowcolumn, chessId, depth);
			break;
		case 4:
			if (IsRed(bp_all.getXY(3)))
				addB_KingMoveForTPos(3, rowcolumn, chessId, depth);
			if (IsRed(bp_all.getXY(5)))
				addB_KingMoveForTPos(5, rowcolumn, chessId, depth);
			if (IsRed(bp_all.getXY(13)))
				addB_KingMoveForTPos(13, rowcolumn, chessId, depth);
			break;
		case 5:
			if (IsRed(bp_all.getXY(4)))
				addB_KingMoveForTPos(4, rowcolumn, chessId, depth);
			if (IsRed(bp_all.getXY(14)))
				addB_KingMoveForTPos(14, rowcolumn, chessId, depth);
			break;
		case 12:
			if (IsRed(bp_all.getXY(3)))
				addB_KingMoveForTPos(3, rowcolumn, chessId, depth);
			if (IsRed(bp_all.getXY(13)))
				addB_KingMoveForTPos(13, rowcolumn, chessId, depth);
			if (IsRed(bp_all.getXY(21)))
				addB_KingMoveForTPos(21, rowcolumn, chessId, depth);
			break;
		case 13:
			if (IsRed(bp_all.getXY(4)))
				addB_KingMoveForTPos(4, rowcolumn, chessId, depth);
			if (IsRed(bp_all.getXY(12)))
				addB_KingMoveForTPos(12, rowcolumn, chessId, depth);
			if (IsRed(bp_all.getXY(14)))
				addB_KingMoveForTPos(14, rowcolumn, chessId, depth);
			if (IsRed(bp_all.getXY(22)))
				addB_KingMoveForTPos(22, rowcolumn, chessId, depth);
			break;
		case 14:
			if (IsRed(bp_all.getXY(5)))
				addB_KingMoveForTPos(5, rowcolumn, chessId, depth);
			if (IsRed(bp_all.getXY(13)))
				addB_KingMoveForTPos(13, rowcolumn, chessId, depth);
			if (IsRed(bp_all.getXY(23)))
				addB_KingMoveForTPos(23, rowcolumn, chessId, depth);
			break;
		case 21:
			if (IsRed(bp_all.getXY(12)))
				addB_KingMoveForTPos(12, rowcolumn, chessId, depth);
			if (IsRed(bp_all.getXY(22)))
				addB_KingMoveForTPos(22, rowcolumn, chessId, depth);
			break;
		case 22:
			if (IsRed(bp_all.getXY(13)))
				addB_KingMoveForTPos(13, rowcolumn, chessId, depth);
			if (IsRed(bp_all.getXY(21)))
				addB_KingMoveForTPos(21, rowcolumn, chessId, depth);
			if (IsRed(bp_all.getXY(23)))
				addB_KingMoveForTPos(23, rowcolumn, chessId, depth);
			break;
		case 23:
			if (IsRed(bp_all.getXY(14)))
				addB_KingMoveForTPos(14, rowcolumn, chessId, depth);
			if (IsRed(bp_all.getXY(22)))
				addB_KingMoveForTPos(22, rowcolumn, chessId, depth);
			break;
		default:
			break;
		}

	}

	private void addMove4B_PAWN(byte rowcolumn, byte chessId, int depth) {
		int row = BitPlane.getRow(rowcolumn);
		int column = BitPlane.getColumn(rowcolumn);

		byte txy;

		if (row > 4) {// 黑兵-过河
			txy = (byte) (rowcolumn + BitPlane.width);
			if (txy < BitPlane.MAX) {// 向上 未出边界
				if (!IsBlack(bp_all.getXY(txy))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(txy);
					move.tRowColumn = txy;
				}
			}

			if ((column - 1) >= 0) {// 左移
				txy = (byte) (rowcolumn - 1);
				if (!IsBlack(bp_all.getXY(txy))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(txy);
					move.tRowColumn = txy;
				}
			}

			if ((column + 1) < BitPlane.width) {// 右移
				txy = (byte) (rowcolumn + 1);
				if (!IsBlack(bp_all.getXY(txy))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(txy);
					move.tRowColumn = txy;
				}
			}

		} else {// 黑兵-未过河
			txy = (byte) (rowcolumn + BitPlane.width);
			if (!IsBlack(bp_all.getXY(txy))) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = bp_all.getXY(txy);
				move.tRowColumn = txy;

			}
		}

	}

	private void addMove4B_PAWN4Chked(byte rowcolumn, byte chessId, int depth) {
		int row = BitPlane.getRow(rowcolumn);
		int column = BitPlane.getColumn(rowcolumn);

		byte txy;

		if (row > 4) {// 黑兵-过河
			txy = (byte) (rowcolumn + BitPlane.width);
			if (txy < BitPlane.MAX) {// 向上 未出边界
				if (!IsBlack(bp_all.getXY(txy))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(txy);
					move.tRowColumn = txy;
					this.makeMove(move);
					if (!this.isBlackKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);
				}
			}

			if ((column - 1) >= 0) {// 左移
				txy = (byte) (rowcolumn - 1);
				if (!IsBlack(bp_all.getXY(txy))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(txy);
					move.tRowColumn = txy;
					this.makeMove(move);
					if (!this.isBlackKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);
				}
			}

			if ((column + 1) < BitPlane.width) {// 右移
				txy = (byte) (rowcolumn + 1);
				if (!IsBlack(bp_all.getXY(txy))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(txy);
					move.tRowColumn = txy;
					this.makeMove(move);
					if (!this.isBlackKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);
				}
			}

		} else {// 黑兵-未过河
			txy = (byte) (rowcolumn + BitPlane.width);
			if (!IsBlack(bp_all.getXY(txy))) {
				ChessMove move = this.m_MoveList[depth][movepos];

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = bp_all.getXY(txy);
				move.tRowColumn = txy;
				this.makeMove(move);
				if (!this.isBlackKingAttacked()) {
					movepos++;
				}
				this.unMakeMove(move);

			}
		}

	}

	private void addMove4B_PAWNAttacking(byte rowcolumn, byte chessId, int depth) {
		int row = BitPlane.getRow(rowcolumn);
		int column = BitPlane.getColumn(rowcolumn);

		byte txy;

		if (row > 4) {// 黑兵-过河
			txy = (byte) (rowcolumn + BitPlane.width);
			if (txy < BitPlane.MAX) {// 向上 未出边界
				if (IsRed(bp_all.getXY(txy))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(txy);
					move.tRowColumn = txy;
				}
			}

			if ((column - 1) >= 0) {// 左移
				txy = (byte) (rowcolumn - 1);
				if (IsRed(bp_all.getXY(txy))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(txy);
					move.tRowColumn = txy;
				}
			}

			if ((column + 1) < BitPlane.width) {// 右移
				txy = (byte) (rowcolumn + 1);
				if (IsRed(bp_all.getXY(txy))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(txy);
					move.tRowColumn = txy;
				}
			}

		} else {// 黑兵-未过河
			txy = (byte) (rowcolumn + BitPlane.width);
			if (IsRed(bp_all.getXY(txy))) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = bp_all.getXY(txy);
				move.tRowColumn = txy;
			}
		}
	}

	private void addMove4R_BISHOP(byte rowcolumn, byte chessId, int depth) {

		byte chessOther;
		if (rowcolumn == 84 || rowcolumn == 86 || rowcolumn == 66
				|| rowcolumn == 68) {
			chessOther = bp_all.getXY(76);
			if (!IsRed(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 76;

			}
		} else if (rowcolumn == 76) {
			chessOther = bp_all.getXY(84);
			if (!IsRed(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 84;

			}
			chessOther = bp_all.getXY(86);
			if (!IsRed(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 86;

			}
			chessOther = bp_all.getXY(66);
			if (!IsRed(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 66;

			}
			chessOther = bp_all.getXY(68);
			if (!IsRed(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 68;

			}
		}

	}

	private void addMove4R_BISHOP4Chked(byte rowcolumn, byte chessId, int depth) {
		byte chessOther;
		if (rowcolumn == 84 || rowcolumn == 86 || rowcolumn == 66
				|| rowcolumn == 68) {
			chessOther = bp_all.getXY(76);
			if (!IsRed(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 76;

				this.makeMove(move);
				if (!this.isRedKingAttacked()) {
					movepos++;
				}
				this.unMakeMove(move);

			}
		} else if (rowcolumn == 76) {
			chessOther = bp_all.getXY(84);
			if (!IsRed(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 84;

				this.makeMove(move);
				if (!this.isRedKingAttacked()) {
					movepos++;
				}
				this.unMakeMove(move);

			}
			chessOther = bp_all.getXY(86);
			if (!IsRed(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 86;

				this.makeMove(move);
				if (!this.isRedKingAttacked()) {
					movepos++;
				}
				this.unMakeMove(move);

			}
			chessOther = bp_all.getXY(66);
			if (!IsRed(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 66;

				this.makeMove(move);
				if (!this.isRedKingAttacked()) {
					movepos++;
				}
				this.unMakeMove(move);

			}
			chessOther = bp_all.getXY(68);
			if (!IsRed(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 68;

				this.makeMove(move);
				if (!this.isRedKingAttacked()) {
					movepos++;
				}
				this.unMakeMove(move);

			}
		}

	}

	private void addMove4R_BISHOPAttacking(byte rowcolumn, byte chessId,
			int depth) {
		byte chessOther;
		if (rowcolumn == 84 || rowcolumn == 86 || rowcolumn == 66
				|| rowcolumn == 68) {
			chessOther = bp_all.getXY(76);
			if (IsBlack(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 76;

			}
		} else if (rowcolumn == 76) {
			chessOther = bp_all.getXY(84);
			if (IsBlack(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 84;

			}
			chessOther = bp_all.getXY(86);
			if (IsBlack(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 86;

			}
			chessOther = bp_all.getXY(66);
			if (IsBlack(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 66;

			}
			chessOther = bp_all.getXY(68);
			if (IsBlack(chessOther)) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = chessOther;
				move.tRowColumn = (byte) 68;

			}
		}

	}

	private void addMove4R_CANON(final byte rowcolumn, byte chessId, int depth) {
		byte row = BitPlane.getRow(rowcolumn);
		// byte column = BitPlane.getColumn(rowcolumn);
		// 行内 <-

		int rowcnt = 0;
		for (int i = rowcolumn - 1; i >= (row * BitPlane.width); i--) {
			final byte xy = bp_all.getXY(i);
			if (xy == 0 && rowcnt == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

			} else {
				if (xy != 0) {
					rowcnt++;
					if (rowcnt == 2) {
						if (!IsSameSide(chessId, xy)) {
							ChessMove move = this.m_MoveList[depth][movepos];
							movepos++;
							move.fChessId = chessId;
							move.fRowColumn = rowcolumn;
							move.tChessId = xy;
							move.tRowColumn = (byte) i;

						}
						break;
					}
				}
			}
		}

		// 行内 ->
		rowcnt = 0;
		for (int i = rowcolumn + 1; i <= (row * BitPlane.width + BitPlane.width - 1); i++) {
			final byte xy = bp_all.getXY(i);
			if (xy == 0 && rowcnt == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

			} else {
				if (xy != 0) {
					rowcnt++;
					if (rowcnt == 2) {
						if (!IsSameSide(chessId, xy)) {
							ChessMove move = this.m_MoveList[depth][movepos];
							movepos++;
							move.fChessId = chessId;
							move.fRowColumn = rowcolumn;
							move.tChessId = xy;
							move.tRowColumn = (byte) i;

						}
						break;
					}
				}
			}
		}

		// 列内 向上
		int columncnt = 0;
		for (int i = rowcolumn - BitPlane.width; i >= 0; i -= BitPlane.width) {
			final byte xy = bp_all.getXY(i);
			if (xy == 0 && columncnt == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

			} else {
				if (xy != 0) {
					columncnt++;
					if (columncnt == 2) {
						if (!IsSameSide(chessId, xy)) {
							ChessMove move = this.m_MoveList[depth][movepos];
							movepos++;
							move.fChessId = chessId;
							move.fRowColumn = rowcolumn;
							move.tChessId = xy;
							move.tRowColumn = (byte) i;

						}
						break;
					}
				}
			}
		}

		// 列内 向下
		columncnt = 0;
		for (int i = rowcolumn + BitPlane.width; i < BitPlane.height
				* BitPlane.width; i += BitPlane.width) {
			final byte xy = bp_all.getXY(i);

			if (xy == 0 && columncnt == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

			} else {
				if (xy != 0) {
					columncnt++;
					if (columncnt == 2) {
						if (!IsSameSide(chessId, xy)) {
							ChessMove move = this.m_MoveList[depth][movepos];
							movepos++;
							move.fChessId = chessId;
							move.fRowColumn = rowcolumn;
							move.tChessId = xy;
							move.tRowColumn = (byte) i;

						}
						break;
					}
				}

			}
		}
	}

	private void addMove4R_CANON4Chked(byte rowcolumn, byte chessId, int depth) {
		byte row = BitPlane.getRow(rowcolumn);
		// byte column = BitPlane.getColumn(rowcolumn);
		// 行内 <-

		int rowcnt = 0;
		for (int i = rowcolumn - 1; i >= (row * BitPlane.width); i--) {
			final byte xy = bp_all.getXY(i);
			if (xy == 0 && rowcnt == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

				this.makeMove(move);
				if (!this.isRedKingAttacked()) {
					movepos++;
				}
				this.unMakeMove(move);

			} else {
				if (xy != 0) {
					rowcnt++;
					if (rowcnt == 2) {
						if (!IsSameSide(chessId, xy)) {
							ChessMove move = this.m_MoveList[depth][movepos];

							move.fChessId = chessId;
							move.fRowColumn = rowcolumn;
							move.tChessId = xy;
							move.tRowColumn = (byte) i;

							this.makeMove(move);
							if (!this.isRedKingAttacked()) {
								movepos++;
							}
							this.unMakeMove(move);

						}
						break;
					}
				}
			}
		}

		// 行内 ->
		rowcnt = 0;
		for (int i = rowcolumn + 1; i <= (row * BitPlane.width + BitPlane.width - 1); i++) {
			final byte xy = bp_all.getXY(i);
			if (xy == 0 && rowcnt == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

				this.makeMove(move);
				if (!this.isRedKingAttacked()) {
					movepos++;
				}
				this.unMakeMove(move);

			} else {
				if (xy != 0) {
					rowcnt++;
					if (rowcnt == 2) {
						if (!IsSameSide(chessId, xy)) {
							ChessMove move = this.m_MoveList[depth][movepos];

							move.fChessId = chessId;
							move.fRowColumn = rowcolumn;
							move.tChessId = xy;
							move.tRowColumn = (byte) i;

							this.makeMove(move);
							if (!this.isRedKingAttacked()) {
								movepos++;
							}
							this.unMakeMove(move);

						}
						break;
					}
				}
			}
		}

		// 列内 向上
		int columncnt = 0;
		for (int i = rowcolumn - BitPlane.width; i >= 0; i -= BitPlane.width) {
			final byte xy = bp_all.getXY(i);
			if (xy == 0 && columncnt == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

				this.makeMove(move);
				if (!this.isRedKingAttacked()) {
					movepos++;
				}
				this.unMakeMove(move);

			} else {
				if (xy != 0) {
					columncnt++;
					if (columncnt == 2) {
						if (!IsSameSide(chessId, xy)) {
							ChessMove move = this.m_MoveList[depth][movepos];

							move.fChessId = chessId;
							move.fRowColumn = rowcolumn;
							move.tChessId = xy;
							move.tRowColumn = (byte) i;

							this.makeMove(move);
							if (!this.isRedKingAttacked()) {
								movepos++;
							}
							this.unMakeMove(move);
						}
						break;
					}
				}
			}
		}

		// 列内 向下
		columncnt = 0;
		for (int i = rowcolumn + BitPlane.width; i < BitPlane.height
				* BitPlane.width; i += BitPlane.width) {
			final byte xy = bp_all.getXY(i);

			if (xy == 0 && columncnt == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

				this.makeMove(move);
				if (!this.isRedKingAttacked()) {
					movepos++;
				}
				this.unMakeMove(move);

			} else {
				if (xy != 0) {
					columncnt++;
					if (columncnt == 2) {
						if (!IsSameSide(chessId, xy)) {
							ChessMove move = this.m_MoveList[depth][movepos];

							move.fChessId = chessId;
							move.fRowColumn = rowcolumn;
							move.tChessId = xy;
							move.tRowColumn = (byte) i;

							this.makeMove(move);
							if (!this.isRedKingAttacked()) {
								movepos++;
							}
							this.unMakeMove(move);

						}
						break;
					}
				}

			}
		}

	}

	private void addMove4R_CANONAttacking(byte rowcolumn, byte chessId,
			int depth) {
		byte row = BitPlane.getRow(rowcolumn);
		// 行内 <-
		int rowcnt = 0;
		for (int i = rowcolumn - 1; i >= (row * BitPlane.width); i--) {
			final byte xy = bp_all.getXY(i);
			if (xy == 0 && rowcnt == 0) {
			} else {
				if (xy != 0) {
					rowcnt++;
					if (rowcnt == 2) {
						if (IsBlack(xy)) {
							ChessMove move = this.m_MoveList[depth][movepos];
							movepos++;
							move.fChessId = chessId;
							move.fRowColumn = rowcolumn;
							move.tChessId = xy;
							move.tRowColumn = (byte) i;

						}
						break;
					}
				}
			}
		}

		// 行内 ->
		rowcnt = 0;
		for (int i = rowcolumn + 1; i <= (row * BitPlane.width + BitPlane.width - 1); i++) {
			final byte xy = bp_all.getXY(i);
			if (xy == 0 && rowcnt == 0) {

			} else {
				if (xy != 0) {
					rowcnt++;
					if (rowcnt == 2) {
						if (IsBlack(xy)) {
							ChessMove move = this.m_MoveList[depth][movepos];
							movepos++;
							move.fChessId = chessId;
							move.fRowColumn = rowcolumn;
							move.tChessId = xy;
							move.tRowColumn = (byte) i;

						}
						break;
					}
				}
			}
		}

		// 列内 向上
		int columncnt = 0;
		for (int i = rowcolumn - BitPlane.width; i >= 0; i -= BitPlane.width) {
			final byte xy = bp_all.getXY(i);
			if (xy == 0 && columncnt == 0) {

			} else {
				if (xy != 0) {
					columncnt++;
					if (columncnt == 2) {
						if (IsBlack(xy)) {
							ChessMove move = this.m_MoveList[depth][movepos];
							movepos++;
							move.fChessId = chessId;
							move.fRowColumn = rowcolumn;
							move.tChessId = xy;
							move.tRowColumn = (byte) i;

						}
						break;
					}
				}
			}
		}

		// 列内 向下
		columncnt = 0;
		for (int i = rowcolumn + BitPlane.width; i < BitPlane.height
				* BitPlane.width; i += BitPlane.width) {
			final byte xy = bp_all.getXY(i);

			if (xy == 0 && columncnt == 0) {

			} else {
				if (xy != 0) {
					columncnt++;
					if (columncnt == 2) {
						if (IsBlack(xy)) {
							ChessMove move = this.m_MoveList[depth][movepos];
							movepos++;
							move.fChessId = chessId;
							move.fRowColumn = rowcolumn;
							move.tChessId = xy;
							move.tRowColumn = (byte) i;

						}
						break;
					}
				}

			}
		}

	}

	private void addMove4R_CAR(final byte rowcolumn, byte chessId, int depth) {

		byte row = BitPlane.getRow(rowcolumn);
		// byte column = BitPlane.getColumn(rowcolumn);

		// 行内 <-
		for (int i = rowcolumn - 1; i >= (row * BitPlane.width); i--) {
			if (bp_all.getXY(i) == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

			} else {
				if (IsBlack(bp_all.getXY(i))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(i);
					move.tRowColumn = (byte) i;

				}
				break;
			}
		}

		// 行内 ->
		for (int i = rowcolumn + 1; i <= (row * BitPlane.width + BitPlane.width - 1); i++) {
			if (bp_all.getXY(i) == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

			} else {
				if (IsBlack(bp_all.getXY(i))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(i);
					move.tRowColumn = (byte) i;

				}
				break;
			}
		}

		// 列内 向上
		for (int i = rowcolumn - BitPlane.width; i >= 0; i -= BitPlane.width) {
			if (bp_all.getXY(i) == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

			} else {
				if (IsBlack(bp_all.getXY(i))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(i);
					move.tRowColumn = (byte) i;

				}
				break;
			}
		}

		// 列内 向下
		for (int i = rowcolumn + BitPlane.width; i < BitPlane.height
				* BitPlane.width; i += BitPlane.width) {
			if (bp_all.getXY(i) == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

			} else {
				if (IsBlack(bp_all.getXY(i))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(i);
					move.tRowColumn = (byte) i;

				}
				break;
			}
		}
	}

	private void addMove4R_CAR4Chked(byte rowcolumn, byte chessId, int depth) {
		byte row = BitPlane.getRow(rowcolumn);
		// byte column = BitPlane.getColumn(rowcolumn);

		// 行内 <-
		for (int i = rowcolumn - 1; i >= (row * BitPlane.width); i--) {
			if (bp_all.getXY(i) == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

				this.makeMove(move);
				if (!this.isRedKingAttacked()) {
					movepos++;
				}
				this.unMakeMove(move);

			} else {
				if (IsBlack(bp_all.getXY(i))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(i);
					move.tRowColumn = (byte) i;

					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);
				}
				break;
			}
		}

		// 行内 ->
		for (int i = rowcolumn + 1; i <= (row * BitPlane.width + BitPlane.width - 1); i++) {
			if (bp_all.getXY(i) == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

				this.makeMove(move);
				if (!this.isRedKingAttacked()) {
					movepos++;
				}
				this.unMakeMove(move);

			} else {
				if (IsBlack(bp_all.getXY(i))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(i);
					move.tRowColumn = (byte) i;

					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);

				}
				break;
			}
		}

		// 列内 向上
		for (int i = rowcolumn - BitPlane.width; i >= 0; i -= BitPlane.width) {
			if (bp_all.getXY(i) == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

				this.makeMove(move);
				if (!this.isRedKingAttacked()) {
					movepos++;
				}
				this.unMakeMove(move);

			} else {
				if (IsBlack(bp_all.getXY(i))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(i);
					move.tRowColumn = (byte) i;

					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);

				}
				break;
			}
		}

		// 列内 向下
		for (int i = rowcolumn + BitPlane.width; i < BitPlane.height
				* BitPlane.width; i += BitPlane.width) {
			if (bp_all.getXY(i) == 0) {
				ChessMove move = this.m_MoveList[depth][movepos];

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = NOCHESS;
				move.tRowColumn = (byte) i;

				this.makeMove(move);
				if (!this.isRedKingAttacked()) {
					movepos++;
				}
				this.unMakeMove(move);

			} else {
				if (IsBlack(bp_all.getXY(i))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(i);
					move.tRowColumn = (byte) i;

					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);

				}
				break;
			}
		}

	}

	private void addMove4R_CARAttacking(byte rowcolumn, byte chessId, int depth) {
		byte row = BitPlane.getRow(rowcolumn);
		// byte column = BitPlane.getColumn(rowcolumn);
		// 行内 <-
		for (int i = rowcolumn - 1; i >= (row * BitPlane.width); i--) {
			final byte txy = bp_all.getXY(i);
			if (txy != 0) {
				if (IsBlack(txy)) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = txy;
					move.tRowColumn = (byte) i;

				}
				break;
			}
		}

		// 行内 ->
		for (int i = rowcolumn + 1; i <= (row * BitPlane.width + BitPlane.width - 1); i++) {
			final byte txy = bp_all.getXY(i);
			if (txy != 0) {
				if (IsBlack(txy)) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = txy;
					move.tRowColumn = (byte) i;

				}
				break;
			}
		}

		// 列内 向上
		for (int i = rowcolumn - BitPlane.width; i >= 0; i -= BitPlane.width) {
			final byte txy = bp_all.getXY(i);
			if (txy != 0) {
				if (IsBlack(txy)) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = txy;
					move.tRowColumn = (byte) i;

				}
				break;
			}
		}

		// 列内 向下
		for (int i = rowcolumn + BitPlane.width; i < BitPlane.height
				* BitPlane.width; i += BitPlane.width) {
			final byte txy = bp_all.getXY(i);
			if (txy != 0) {
				if (IsBlack(txy)) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = txy;
					move.tRowColumn = (byte) i;

				}
				break;
			}
		}

	}

	// 5-2 5-6
	// 7-0 7-4 7-8
	// 9-2 9-6
	// ______47______51
	// ____55__57__59___61
	// __63______67_______71
	// ____73__75__77___79
	// ______83______87
	private void addMove4R_ELEPHANT(byte rowcolumn, byte chessId, int depth) {

		switch (rowcolumn) {
		case 47:
			if (bp_all.getXY(55) == NOCHESS) {
				if (!IsRed(bp_all.getXY(63))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(63);
					move.tRowColumn = 63;

				}
			}
			if (bp_all.getXY(57) == NOCHESS) {
				if (!IsRed(bp_all.getXY(67))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(67);
					move.tRowColumn = 67;

				}
			}
			break;
		case 51:
			if (bp_all.getXY(59) == NOCHESS) {
				if (!IsRed(bp_all.getXY(67))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(67);
					move.tRowColumn = 67;

				}
			}
			if (bp_all.getXY(61) == NOCHESS) {
				if (!IsRed(bp_all.getXY(71))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(71);
					move.tRowColumn = 71;

				}
			}
			break;

		case 63:
			if (bp_all.getXY(55) == NOCHESS) {
				if (!IsRed(bp_all.getXY(47))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(47);
					move.tRowColumn = 47;
				}
			}
			if (bp_all.getXY(73) == NOCHESS) {
				if (!IsRed(bp_all.getXY(83))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(83);
					move.tRowColumn = 83;

				}
			}
			break;
		case 67:
			if (bp_all.getXY(57) == NOCHESS) {
				if (!IsRed(bp_all.getXY(47))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(47);
					move.tRowColumn = 47;

				}
			}
			if (bp_all.getXY(59) == NOCHESS) {
				if (!IsRed(bp_all.getXY(51))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(51);
					move.tRowColumn = 51;

				}
			}
			if (bp_all.getXY(75) == NOCHESS) {
				if (!IsRed(bp_all.getXY(83))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(83);
					move.tRowColumn = 83;

				}
			}
			if (bp_all.getXY(77) == NOCHESS) {
				if (!IsRed(bp_all.getXY(87))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(87);
					move.tRowColumn = 87;

				}
			}
			break;
		case 71:
			if (bp_all.getXY(61) == NOCHESS) {
				if (!IsRed(bp_all.getXY(51))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(51);
					move.tRowColumn = 51;

				}
			}
			if (bp_all.getXY(79) == NOCHESS) {
				if (!IsRed(bp_all.getXY(87))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(87);
					move.tRowColumn = 87;

				}
			}
			break;
		case 83:
			if (bp_all.getXY(73) == NOCHESS) {
				if (!IsRed(bp_all.getXY(63))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(63);
					move.tRowColumn = 63;

				}
			}
			if (bp_all.getXY(75) == NOCHESS) {
				if (!IsRed(bp_all.getXY(67))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(67);
					move.tRowColumn = 67;

				}
			}
			break;
		case 87:
			if (bp_all.getXY(77) == NOCHESS) {
				if (!IsRed(bp_all.getXY(67))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(67);
					move.tRowColumn = 67;

				}
			}
			if (bp_all.getXY(79) == NOCHESS) {
				if (!IsRed(bp_all.getXY(71))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(71);
					move.tRowColumn = 71;

				}
			}
			break;
		default:
			break;
		}

	}

	private void addMove4R_ELEPHANT4Chked(byte rowcolumn, byte chessId,
			int depth) {
		switch (rowcolumn) {
		case 47:
			if (bp_all.getXY(55) == NOCHESS) {
				if (!IsRed(bp_all.getXY(63))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(63);
					move.tRowColumn = 63;

					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);

				}
			}
			if (bp_all.getXY(57) == NOCHESS) {
				if (!IsRed(bp_all.getXY(67))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(67);
					move.tRowColumn = 67;

					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);

				}
			}
			break;
		case 51:
			if (bp_all.getXY(59) == NOCHESS) {
				if (!IsRed(bp_all.getXY(67))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(67);
					move.tRowColumn = 67;

					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);

				}
			}
			if (bp_all.getXY(61) == NOCHESS) {
				if (!IsRed(bp_all.getXY(71))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(71);
					move.tRowColumn = 71;

					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);

				}
			}
			break;

		case 63:
			if (bp_all.getXY(55) == NOCHESS) {
				if (!IsRed(bp_all.getXY(47))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(47);
					move.tRowColumn = 47;

					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);
				}
			}
			if (bp_all.getXY(73) == NOCHESS) {
				if (!IsRed(bp_all.getXY(83))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(83);
					move.tRowColumn = 83;

					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);

				}
			}
			break;
		case 67:
			if (bp_all.getXY(57) == NOCHESS) {
				if (!IsRed(bp_all.getXY(47))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(47);
					move.tRowColumn = 47;

					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);

				}
			}
			if (bp_all.getXY(59) == NOCHESS) {
				if (!IsRed(bp_all.getXY(51))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(51);
					move.tRowColumn = 51;

					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);

				}
			}
			if (bp_all.getXY(75) == NOCHESS) {
				if (!IsRed(bp_all.getXY(83))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(83);
					move.tRowColumn = 83;

					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);

				}
			}
			if (bp_all.getXY(77) == NOCHESS) {
				if (!IsRed(bp_all.getXY(87))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(87);
					move.tRowColumn = 87;

					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);

				}
			}
			break;
		case 71:
			if (bp_all.getXY(61) == NOCHESS) {
				if (!IsRed(bp_all.getXY(51))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(51);
					move.tRowColumn = 51;

					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);

				}
			}
			if (bp_all.getXY(79) == NOCHESS) {
				if (!IsRed(bp_all.getXY(87))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(87);
					move.tRowColumn = 87;

					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);

				}
			}
			break;
		case 83:
			if (bp_all.getXY(73) == NOCHESS) {
				if (!IsRed(bp_all.getXY(63))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(63);
					move.tRowColumn = 63;

					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);

				}
			}
			if (bp_all.getXY(75) == NOCHESS) {
				if (!IsRed(bp_all.getXY(67))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(67);
					move.tRowColumn = 67;

					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);

				}
			}
			break;
		case 87:
			if (bp_all.getXY(77) == NOCHESS) {
				if (!IsRed(bp_all.getXY(67))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(67);
					move.tRowColumn = 67;

					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);

				}
			}
			if (bp_all.getXY(79) == NOCHESS) {
				if (!IsRed(bp_all.getXY(71))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(71);
					move.tRowColumn = 71;

					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);

				}
			}
			break;
		default:
			break;
		}

	}

	private void addMove4R_ELEPHANTAttacking(byte rowcolumn, byte chessId,
			int depth) {
		switch (rowcolumn) {
		case 47:
			if (bp_all.getXY(55) == NOCHESS) {
				if (IsBlack(bp_all.getXY(63))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(63);
					move.tRowColumn = 63;

				}
			}
			if (bp_all.getXY(57) == NOCHESS) {
				if (IsBlack(bp_all.getXY(67))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(67);
					move.tRowColumn = 67;

				}
			}
			break;
		case 51:
			if (bp_all.getXY(59) == NOCHESS) {
				if (IsBlack(bp_all.getXY(67))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(67);
					move.tRowColumn = 67;

				}
			}
			if (bp_all.getXY(61) == NOCHESS) {
				if (IsBlack(bp_all.getXY(71))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(71);
					move.tRowColumn = 71;

				}
			}
			break;

		case 63:
			if (bp_all.getXY(55) == NOCHESS) {
				if (IsBlack(bp_all.getXY(47))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(47);
					move.tRowColumn = 47;
				}
			}
			if (bp_all.getXY(73) == NOCHESS) {
				if (IsBlack(bp_all.getXY(83))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(83);
					move.tRowColumn = 83;

				}
			}
			break;
		case 67:
			if (bp_all.getXY(57) == NOCHESS) {
				if (IsBlack(bp_all.getXY(47))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(47);
					move.tRowColumn = 47;

				}
			}
			if (bp_all.getXY(59) == NOCHESS) {
				if (IsBlack(bp_all.getXY(51))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(51);
					move.tRowColumn = 51;

				}
			}
			if (bp_all.getXY(75) == NOCHESS) {
				if (IsBlack(bp_all.getXY(83))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(83);
					move.tRowColumn = 83;

				}
			}
			if (bp_all.getXY(77) == NOCHESS) {
				if (IsBlack(bp_all.getXY(87))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(87);
					move.tRowColumn = 87;

				}
			}
			break;
		case 71:
			if (bp_all.getXY(61) == NOCHESS) {
				if (IsBlack(bp_all.getXY(51))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(51);
					move.tRowColumn = 51;

				}
			}
			if (bp_all.getXY(79) == NOCHESS) {
				if (IsBlack(bp_all.getXY(87))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(87);
					move.tRowColumn = 87;

				}
			}
			break;
		case 83:
			if (bp_all.getXY(73) == NOCHESS) {
				if (IsBlack(bp_all.getXY(63))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(63);
					move.tRowColumn = 63;

				}
			}
			if (bp_all.getXY(75) == NOCHESS) {
				if (IsBlack(bp_all.getXY(67))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(67);
					move.tRowColumn = 67;

				}
			}
			break;
		case 87:
			if (bp_all.getXY(77) == NOCHESS) {
				if (IsBlack(bp_all.getXY(67))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(67);
					move.tRowColumn = 67;

				}
			}
			if (bp_all.getXY(79) == NOCHESS) {
				if (IsBlack(bp_all.getXY(71))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = R_ELEPHANT;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(71);
					move.tRowColumn = 71;

				}
			}
			break;
		default:
			break;
		}

	}

	private void addMove4R_HORSE(final byte rowcolumn, byte chessId, int depth) {
		byte row = BitPlane.getRow(rowcolumn);
		byte column = BitPlane.getColumn(rowcolumn);

		byte target = -1;
		byte middle = -1;

		byte trow = (byte) (row - 2);
		byte tcolumn = (byte) (column - 1);
		if (trow >= 0 && tcolumn >= 0) {
			target = bp_all.getXY(trow, tcolumn);
			if (!IsRed(target)) {
				middle = bp_all.getXY((byte) (row - 1), column);
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn - 2 * BitPlane.width - 1);

				}
			}
		}

		trow = (byte) (row - 2);
		tcolumn = (byte) (column + 1);
		if (trow >= 0 && tcolumn < BitPlane.width) {
			target = bp_all.getXY(rowcolumn - 2 * BitPlane.width + 1);
			if (!IsRed(target)) {
				middle = bp_all.getXY((byte) (row - 1), column);
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn - 2 * BitPlane.width + 1);

				}
			}
		}

		trow = (byte) (row - 1);
		tcolumn = (byte) (column - 2);
		if (trow >= 0 && tcolumn >= 0) {
			target = bp_all.getXY(rowcolumn - BitPlane.width - 2);
			if (!IsRed(target)) {
				middle = bp_all.getXY(row, (byte) (column - 1));
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn - BitPlane.width - 2);

				}
			}
		}

		trow = (byte) (row - 1);
		tcolumn = (byte) (column + 2);
		if (trow >= 0 && tcolumn < BitPlane.width) {
			target = bp_all.getXY(rowcolumn - BitPlane.width + 2);
			if (!IsRed(target)) {
				middle = bp_all.getXY(row, (byte) (column + 1));
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn - BitPlane.width + 2);

				}
			}
		}

		trow = (byte) (row + 1);
		tcolumn = (byte) (column - 2);
		if (trow < BitPlane.height && tcolumn >= 0) {
			target = bp_all.getXY(rowcolumn + BitPlane.width - 2);
			if (!IsRed(target)) {
				middle = bp_all.getXY(row, (byte) (column - 1));
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn + BitPlane.width - 2);

				}
			}
		}

		trow = (byte) (row + 1);
		tcolumn = (byte) (column + 2);
		if (trow < BitPlane.height && tcolumn < BitPlane.width) {
			target = bp_all.getXY(rowcolumn + BitPlane.width + 2);
			if (!IsRed(target)) {
				middle = bp_all.getXY(row, (byte) (column + 1));
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn + BitPlane.width + 2);

				}
			}
		}

		trow = (byte) (row + 2);
		tcolumn = (byte) (column - 1);
		if (trow < BitPlane.height && tcolumn >= 0) {
			target = bp_all.getXY(rowcolumn + 2 * BitPlane.width - 1);
			if (!IsRed(target)) {
				middle = bp_all.getXY((byte) (row + 1), column);
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn + 2 * BitPlane.width - 1);

				}
			}
		}

		trow = (byte) (row + 2);
		tcolumn = (byte) (column + 1);
		if (trow < BitPlane.height && tcolumn < BitPlane.width) {
			target = bp_all.getXY(rowcolumn + 2 * BitPlane.width + 1);
			if (!IsRed(target)) {
				middle = bp_all.getXY((byte) (row + 1), column);
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn + 2 * BitPlane.width + 1);

				}
			}
		}

	}

	private void addMove4R_HORSE4Chked(byte rowcolumn, byte chessId, int depth) {
		byte row = BitPlane.getRow(rowcolumn);
		byte column = BitPlane.getColumn(rowcolumn);

		byte target = -1;
		byte middle = -1;

		byte trow = (byte) (row - 2);
		byte tcolumn = (byte) (column - 1);
		if (trow >= 0 && tcolumn >= 0) {
			target = bp_all.getXY(trow, tcolumn);
			if (!IsRed(target)) {
				middle = bp_all.getXY((byte) (row - 1), column);
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn - 2 * BitPlane.width - 1);
					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);
				}
			}
		}

		trow = (byte) (row - 2);
		tcolumn = (byte) (column + 1);
		if (trow >= 0 && tcolumn < BitPlane.width) {
			target = bp_all.getXY(rowcolumn - 2 * BitPlane.width + 1);
			if (!IsRed(target)) {
				middle = bp_all.getXY((byte) (row - 1), column);
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn - 2 * BitPlane.width + 1);
					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);
				}
			}
		}

		trow = (byte) (row - 1);
		tcolumn = (byte) (column - 2);
		if (trow >= 0 && tcolumn >= 0) {
			target = bp_all.getXY(rowcolumn - BitPlane.width - 2);
			if (!IsRed(target)) {
				middle = bp_all.getXY(row, (byte) (column - 1));
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn - BitPlane.width - 2);
					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);
				}
			}
		}

		trow = (byte) (row - 1);
		tcolumn = (byte) (column + 2);
		if (trow >= 0 && tcolumn < BitPlane.width) {
			target = bp_all.getXY(rowcolumn - BitPlane.width + 2);
			if (!IsRed(target)) {
				middle = bp_all.getXY(row, (byte) (column + 1));
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn - BitPlane.width + 2);
					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);
				}
			}
		}

		trow = (byte) (row + 1);
		tcolumn = (byte) (column - 2);
		if (trow < BitPlane.height && tcolumn >= 0) {
			target = bp_all.getXY(rowcolumn + BitPlane.width - 2);
			if (!IsRed(target)) {
				middle = bp_all.getXY(row, (byte) (column - 1));
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn + BitPlane.width - 2);
					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);
				}
			}
		}

		trow = (byte) (row + 1);
		tcolumn = (byte) (column + 2);
		if (trow < BitPlane.height && tcolumn < BitPlane.width) {
			target = bp_all.getXY(rowcolumn + BitPlane.width + 2);
			if (!IsRed(target)) {
				middle = bp_all.getXY(row, (byte) (column + 1));
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn + BitPlane.width + 2);
					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);
				}
			}
		}

		trow = (byte) (row + 2);
		tcolumn = (byte) (column - 1);
		if (trow < BitPlane.height && tcolumn >= 0) {
			target = bp_all.getXY(rowcolumn + 2 * BitPlane.width - 1);
			if (!IsRed(target)) {
				middle = bp_all.getXY((byte) (row + 1), column);
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn + 2 * BitPlane.width - 1);
					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);
				}
			}
		}

		trow = (byte) (row + 2);
		tcolumn = (byte) (column + 1);
		if (trow < BitPlane.height && tcolumn < BitPlane.width) {
			target = bp_all.getXY(rowcolumn + 2 * BitPlane.width + 1);
			if (!IsRed(target)) {
				middle = bp_all.getXY((byte) (row + 1), column);
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn + 2 * BitPlane.width + 1);
					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);
				}
			}
		}

	}

	private void addMove4R_HORSEAttacking(byte rowcolumn, byte chessId,
			int depth) {
		byte row = BitPlane.getRow(rowcolumn);
		byte column = BitPlane.getColumn(rowcolumn);

		byte target = -1;
		byte middle = -1;

		byte trow = (byte) (row - 2);
		byte tcolumn = (byte) (column - 1);
		if (trow >= 0 && tcolumn >= 0) {
			target = bp_all.getXY(trow, tcolumn);
			if (IsBlack(target)) {
				middle = bp_all.getXY((byte) (row - 1), column);
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn - 2 * BitPlane.width - 1);

				}
			}
		}

		trow = (byte) (row - 2);
		tcolumn = (byte) (column + 1);
		if (trow >= 0 && tcolumn < BitPlane.width) {
			target = bp_all.getXY(rowcolumn - 2 * BitPlane.width + 1);
			if (IsBlack(target)) {
				middle = bp_all.getXY((byte) (row - 1), column);
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn - 2 * BitPlane.width + 1);

				}
			}
		}

		trow = (byte) (row - 1);
		tcolumn = (byte) (column - 2);
		if (trow >= 0 && tcolumn >= 0) {
			target = bp_all.getXY(rowcolumn - BitPlane.width - 2);
			if (IsBlack(target)) {
				middle = bp_all.getXY(row, (byte) (column - 1));
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn - BitPlane.width - 2);

				}
			}
		}

		trow = (byte) (row - 1);
		tcolumn = (byte) (column + 2);
		if (trow >= 0 && tcolumn < BitPlane.width) {
			target = bp_all.getXY(rowcolumn - BitPlane.width + 2);
			if (IsBlack(target)) {
				middle = bp_all.getXY(row, (byte) (column + 1));
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn - BitPlane.width + 2);

				}
			}
		}

		trow = (byte) (row + 1);
		tcolumn = (byte) (column - 2);
		if (trow < BitPlane.height && tcolumn >= 0) {
			target = bp_all.getXY(rowcolumn + BitPlane.width - 2);
			if (IsBlack(target)) {
				middle = bp_all.getXY(row, (byte) (column - 1));
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn + BitPlane.width - 2);

				}
			}
		}

		trow = (byte) (row + 1);
		tcolumn = (byte) (column + 2);
		if (trow < BitPlane.height && tcolumn < BitPlane.width) {
			target = bp_all.getXY(rowcolumn + BitPlane.width + 2);
			if (IsBlack(target)) {
				middle = bp_all.getXY(row, (byte) (column + 1));
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn + BitPlane.width + 2);

				}
			}
		}

		trow = (byte) (row + 2);
		tcolumn = (byte) (column - 1);
		if (trow < BitPlane.height && tcolumn >= 0) {
			target = bp_all.getXY(rowcolumn + 2 * BitPlane.width - 1);
			if (IsBlack(target)) {
				middle = bp_all.getXY((byte) (row + 1), column);
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn + 2 * BitPlane.width - 1);

				}
			}
		}

		trow = (byte) (row + 2);
		tcolumn = (byte) (column + 1);
		if (trow < BitPlane.height && tcolumn < BitPlane.width) {
			target = bp_all.getXY(rowcolumn + 2 * BitPlane.width + 1);
			if (IsBlack(target)) {
				middle = bp_all.getXY((byte) (row + 1), column);
				if (middle == NOCHESS) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = target;
					move.tRowColumn = (byte) (rowcolumn + 2 * BitPlane.width + 1);

				}
			}
		}

	}

	// _________66_67_68 ________
	// _________75 76 77 ________
	// _________84 85 86 ________
	private void addMove4R_KING(byte rowcolumn, byte chessId, int depth) {

		// byte row = BitPlane.getRow(rowcolumn);
		// byte column = BitPlane.getColumn(rowcolumn);

		byte oxy = -1;
		byte[] p = ChessBoardBitPlanes.Pos_B_KING;
		for (int i = 0; i < p.length; i++) {
			byte pos = p[i];
			if (bp_all.getXY(pos) == B_KING) {
				oxy = pos;
				break;
			}
		}

		if (oxy > -1) {
			// byte or = BitPlane.getRow(oxy);
			// byte oc = BitPlane.getColumn(oxy);
			if ((rowcolumn - oxy) % 9 == 0) {
				boolean block = false;
				for (int i = oxy + 9; i < rowcolumn; i += 9) {
					if (bp_all.getXY(i) != NOCHESS) {
						block = true;
						break;
					}
				}
				if (!block) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = B_KING;
					move.tRowColumn = (byte) oxy;
				}
			}
		}

		switch (rowcolumn) {
		case 84:
			addR_KingMoveForTPos(75, rowcolumn, chessId, depth);
			addR_KingMoveForTPos(85, rowcolumn, chessId, depth);
			break;
		case 85:
			addR_KingMoveForTPos(84, rowcolumn, chessId, depth);
			addR_KingMoveForTPos(86, rowcolumn, chessId, depth);
			addR_KingMoveForTPos(76, rowcolumn, chessId, depth);
			break;
		case 86:
			addR_KingMoveForTPos(85, rowcolumn, chessId, depth);
			addR_KingMoveForTPos(77, rowcolumn, chessId, depth);
			break;
		case 75:
			addR_KingMoveForTPos(66, rowcolumn, chessId, depth);
			addR_KingMoveForTPos(76, rowcolumn, chessId, depth);
			addR_KingMoveForTPos(84, rowcolumn, chessId, depth);
			break;
		case 76:
			addR_KingMoveForTPos(75, rowcolumn, chessId, depth);
			addR_KingMoveForTPos(77, rowcolumn, chessId, depth);
			addR_KingMoveForTPos(67, rowcolumn, chessId, depth);
			addR_KingMoveForTPos(85, rowcolumn, chessId, depth);
			break;
		case 77:
			addR_KingMoveForTPos(76, rowcolumn, chessId, depth);
			addR_KingMoveForTPos(68, rowcolumn, chessId, depth);
			addR_KingMoveForTPos(86, rowcolumn, chessId, depth);
			break;
		case 66:
			addR_KingMoveForTPos(75, rowcolumn, chessId, depth);
			addR_KingMoveForTPos(67, rowcolumn, chessId, depth);
			break;
		case 67:
			addR_KingMoveForTPos(66, rowcolumn, chessId, depth);
			addR_KingMoveForTPos(76, rowcolumn, chessId, depth);
			addR_KingMoveForTPos(68, rowcolumn, chessId, depth);
			break;
		case 68:
			addR_KingMoveForTPos(67, rowcolumn, chessId, depth);
			addR_KingMoveForTPos(77, rowcolumn, chessId, depth);
			break;
		default:
			break;
		}

	}

	private void addMove4R_KING4Chked(byte rowcolumn, byte chessId, int depth) {

		byte txy = this.b_king_pos;
		byte tcolumn = (byte) (txy % 9);
		byte trow = (byte) (txy / 9);

		byte fcolumn = (byte) (rowcolumn % 9);
		byte frow = (byte) (rowcolumn / 9);

		if (fcolumn - tcolumn == 1 || fcolumn - tcolumn == -1) {
			boolean block = false;
			for (int row = frow - 1; row > trow; row--) {
				if (this.getXY(row, tcolumn) != NOCHESS) {
					block = true;
					break;
				}
			}

			if (fcolumn - tcolumn == 1) {
				if (block) {
					switch (rowcolumn) {
					case 84:
						addR_KingMoveForTPos4Chked(75, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(85, rowcolumn, chessId,
								depth);
						break;
					case 85:
						addR_KingMoveForTPos4Chked(84, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(86, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(76, rowcolumn, chessId,
								depth);
						break;
					case 86:
						addR_KingMoveForTPos4Chked(85, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(77, rowcolumn, chessId,
								depth);
						break;
					case 75:
						addR_KingMoveForTPos4Chked(66, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(76, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(84, rowcolumn, chessId,
								depth);
						break;
					case 76:
						addR_KingMoveForTPos4Chked(75, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(77, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(67, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(85, rowcolumn, chessId,
								depth);
						break;
					case 77:
						addR_KingMoveForTPos4Chked(76, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(68, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(86, rowcolumn, chessId,
								depth);
						break;
					case 66:
						addR_KingMoveForTPos4Chked(75, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(67, rowcolumn, chessId,
								depth);
						break;
					case 67:
						addR_KingMoveForTPos4Chked(66, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(76, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(68, rowcolumn, chessId,
								depth);
						break;
					case 68:
						addR_KingMoveForTPos4Chked(67, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(77, rowcolumn, chessId,
								depth);
						break;
					default:
						break;
					}
				} else {
					switch (rowcolumn) {
					case 84:
						addR_KingMoveForTPos4Chked(75, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(85, rowcolumn, chessId,
								depth);
						break;
					case 85:
						// addR_KingMoveForTPos4Chked(84, rowcolumn, chessId,
						// depth);
						addR_KingMoveForTPos4Chked(86, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(76, rowcolumn, chessId,
								depth);
						break;
					case 86:
						// addR_KingMoveForTPos4Chked(85, rowcolumn, chessId,
						// depth);
						addR_KingMoveForTPos4Chked(77, rowcolumn, chessId,
								depth);
						break;
					case 75:
						addR_KingMoveForTPos4Chked(66, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(76, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(84, rowcolumn, chessId,
								depth);
						break;
					case 76:
						// addR_KingMoveForTPos4Chked(75, rowcolumn, chessId,
						// depth);
						addR_KingMoveForTPos4Chked(77, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(67, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(85, rowcolumn, chessId,
								depth);
						break;
					case 77:
						// addR_KingMoveForTPos4Chked(76, rowcolumn, chessId,
						// depth);
						addR_KingMoveForTPos4Chked(68, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(86, rowcolumn, chessId,
								depth);
						break;
					case 66:
						addR_KingMoveForTPos4Chked(75, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(67, rowcolumn, chessId,
								depth);
						break;
					case 67:
						// addR_KingMoveForTPos4Chked(66, rowcolumn, chessId,
						// depth);
						addR_KingMoveForTPos4Chked(76, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(68, rowcolumn, chessId,
								depth);
						break;
					case 68:
						// addR_KingMoveForTPos4Chked(67, rowcolumn, chessId,
						// depth);
						addR_KingMoveForTPos4Chked(77, rowcolumn, chessId,
								depth);
						break;
					default:
						break;
					}
				}

			} else {
				if (block) {
					switch (rowcolumn) {
					case 84:
						addR_KingMoveForTPos4Chked(75, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(85, rowcolumn, chessId,
								depth);
						break;
					case 85:
						addR_KingMoveForTPos4Chked(84, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(86, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(76, rowcolumn, chessId,
								depth);
						break;
					case 86:
						addR_KingMoveForTPos4Chked(85, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(77, rowcolumn, chessId,
								depth);
						break;
					case 75:
						addR_KingMoveForTPos4Chked(66, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(76, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(84, rowcolumn, chessId,
								depth);
						break;
					case 76:
						addR_KingMoveForTPos4Chked(75, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(77, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(67, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(85, rowcolumn, chessId,
								depth);
						break;
					case 77:
						addR_KingMoveForTPos4Chked(76, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(68, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(86, rowcolumn, chessId,
								depth);
						break;
					case 66:
						addR_KingMoveForTPos4Chked(75, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(67, rowcolumn, chessId,
								depth);
						break;
					case 67:
						addR_KingMoveForTPos4Chked(66, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(76, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(68, rowcolumn, chessId,
								depth);
						break;
					case 68:
						addR_KingMoveForTPos4Chked(67, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(77, rowcolumn, chessId,
								depth);
						break;
					default:
						break;
					}
				} else {
					switch (rowcolumn) {
					case 84:
						addR_KingMoveForTPos4Chked(75, rowcolumn, chessId,
								depth);
						// addR_KingMoveForTPos4Chked(85, rowcolumn, chessId,
						// depth);
						break;
					case 85:
						addR_KingMoveForTPos4Chked(84, rowcolumn, chessId,
								depth);
						// addR_KingMoveForTPos4Chked(86, rowcolumn, chessId,
						// depth);
						addR_KingMoveForTPos4Chked(76, rowcolumn, chessId,
								depth);
						break;
					case 86:
						addR_KingMoveForTPos4Chked(85, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(77, rowcolumn, chessId,
								depth);
						break;
					case 75:
						addR_KingMoveForTPos4Chked(66, rowcolumn, chessId,
								depth);
						// addR_KingMoveForTPos4Chked(76, rowcolumn, chessId,
						// depth);
						addR_KingMoveForTPos4Chked(84, rowcolumn, chessId,
								depth);
						break;
					case 76:
						addR_KingMoveForTPos4Chked(75, rowcolumn, chessId,
								depth);
						// addR_KingMoveForTPos4Chked(77, rowcolumn, chessId,
						// depth);
						addR_KingMoveForTPos4Chked(67, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(85, rowcolumn, chessId,
								depth);
						break;
					case 77:
						addR_KingMoveForTPos4Chked(76, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(68, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(86, rowcolumn, chessId,
								depth);
						break;
					case 66:
						addR_KingMoveForTPos4Chked(75, rowcolumn, chessId,
								depth);
						// addR_KingMoveForTPos4Chked(67, rowcolumn, chessId,
						// depth);
						break;
					case 67:
						addR_KingMoveForTPos4Chked(66, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(76, rowcolumn, chessId,
								depth);
						// addR_KingMoveForTPos4Chked(68, rowcolumn, chessId,
						// depth);
						break;
					case 68:
						addR_KingMoveForTPos4Chked(67, rowcolumn, chessId,
								depth);
						addR_KingMoveForTPos4Chked(77, rowcolumn, chessId,
								depth);
						break;
					default:
						break;
					}
				}

			}

		} else {
			switch (rowcolumn) {
			case 84:
				addR_KingMoveForTPos4Chked(75, rowcolumn, chessId, depth);
				addR_KingMoveForTPos4Chked(85, rowcolumn, chessId, depth);
				break;
			case 85:
				addR_KingMoveForTPos4Chked(84, rowcolumn, chessId, depth);
				addR_KingMoveForTPos4Chked(86, rowcolumn, chessId, depth);
				addR_KingMoveForTPos4Chked(76, rowcolumn, chessId, depth);
				break;
			case 86:
				addR_KingMoveForTPos4Chked(85, rowcolumn, chessId, depth);
				addR_KingMoveForTPos4Chked(77, rowcolumn, chessId, depth);
				break;
			case 75:
				addR_KingMoveForTPos4Chked(66, rowcolumn, chessId, depth);
				addR_KingMoveForTPos4Chked(76, rowcolumn, chessId, depth);
				addR_KingMoveForTPos4Chked(84, rowcolumn, chessId, depth);
				break;
			case 76:
				addR_KingMoveForTPos4Chked(75, rowcolumn, chessId, depth);
				addR_KingMoveForTPos4Chked(77, rowcolumn, chessId, depth);
				addR_KingMoveForTPos4Chked(67, rowcolumn, chessId, depth);
				addR_KingMoveForTPos4Chked(85, rowcolumn, chessId, depth);
				break;
			case 77:
				addR_KingMoveForTPos4Chked(76, rowcolumn, chessId, depth);
				addR_KingMoveForTPos4Chked(68, rowcolumn, chessId, depth);
				addR_KingMoveForTPos4Chked(86, rowcolumn, chessId, depth);
				break;
			case 66:
				addR_KingMoveForTPos4Chked(75, rowcolumn, chessId, depth);
				addR_KingMoveForTPos4Chked(67, rowcolumn, chessId, depth);
				break;
			case 67:
				addR_KingMoveForTPos4Chked(66, rowcolumn, chessId, depth);
				addR_KingMoveForTPos4Chked(76, rowcolumn, chessId, depth);
				addR_KingMoveForTPos4Chked(68, rowcolumn, chessId, depth);
				break;
			case 68:
				addR_KingMoveForTPos4Chked(67, rowcolumn, chessId, depth);
				addR_KingMoveForTPos4Chked(77, rowcolumn, chessId, depth);
				break;
			default:
				break;
			}
		}

	}

	private void addMove4R_KINGAttacking(byte rowcolumn, byte chessId, int depth) {
		byte oxy = -1;
		byte[] p = ChessBoardBitPlanes.Pos_B_KING;
		for (int i = 0; i < p.length; i++) {
			byte pos = p[i];
			if (bp_all.getXY(pos) == B_KING) {
				oxy = pos;
				break;
			}
		}

		if (oxy > -1) {
			// byte or = BitPlane.getRow(oxy);
			// byte oc = BitPlane.getColumn(oxy);
			if ((rowcolumn - oxy) % 9 == 0) {
				boolean block = false;
				for (int i = oxy + 9; i < rowcolumn; i += 9) {
					if (bp_all.getXY(i) != NOCHESS) {
						block = true;
						break;
					}
				}
				if (!block) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = B_KING;
					move.tRowColumn = (byte) oxy;
				}
			}
		}

		switch (rowcolumn) {
		case 84:
			if (IsBlack(bp_all.getXY(75)))
				addR_KingMoveForTPos(75, rowcolumn, chessId, depth);
			if (IsBlack(bp_all.getXY(85)))
				addR_KingMoveForTPos(85, rowcolumn, chessId, depth);
			break;
		case 85:
			if (IsBlack(bp_all.getXY(84)))
				addR_KingMoveForTPos(84, rowcolumn, chessId, depth);
			if (IsBlack(bp_all.getXY(86)))
				addR_KingMoveForTPos(86, rowcolumn, chessId, depth);
			if (IsBlack(bp_all.getXY(76)))
				addR_KingMoveForTPos(76, rowcolumn, chessId, depth);
			break;
		case 86:
			if (IsBlack(bp_all.getXY(85)))
				addR_KingMoveForTPos(85, rowcolumn, chessId, depth);
			if (IsBlack(bp_all.getXY(77)))
				addR_KingMoveForTPos(77, rowcolumn, chessId, depth);
			break;
		case 75:
			if (IsBlack(bp_all.getXY(66)))
				addR_KingMoveForTPos(66, rowcolumn, chessId, depth);
			if (IsBlack(bp_all.getXY(76)))
				addR_KingMoveForTPos(76, rowcolumn, chessId, depth);
			if (IsBlack(bp_all.getXY(84)))
				addR_KingMoveForTPos(84, rowcolumn, chessId, depth);
			break;
		case 76:
			if (IsBlack(bp_all.getXY(75)))
				addR_KingMoveForTPos(75, rowcolumn, chessId, depth);
			if (IsBlack(bp_all.getXY(77)))
				addR_KingMoveForTPos(77, rowcolumn, chessId, depth);
			if (IsBlack(bp_all.getXY(67)))
				addR_KingMoveForTPos(67, rowcolumn, chessId, depth);
			if (IsBlack(bp_all.getXY(85)))
				addR_KingMoveForTPos(85, rowcolumn, chessId, depth);
			break;
		case 77:
			if (IsBlack(bp_all.getXY(76)))
				addR_KingMoveForTPos(76, rowcolumn, chessId, depth);
			if (IsBlack(bp_all.getXY(68)))
				addR_KingMoveForTPos(68, rowcolumn, chessId, depth);
			if (IsBlack(bp_all.getXY(86)))
				addR_KingMoveForTPos(86, rowcolumn, chessId, depth);
			break;
		case 66:
			if (IsBlack(bp_all.getXY(75)))
				addR_KingMoveForTPos(75, rowcolumn, chessId, depth);
			if (IsBlack(bp_all.getXY(67)))
				addR_KingMoveForTPos(67, rowcolumn, chessId, depth);
			break;
		case 67:
			if (IsBlack(bp_all.getXY(66)))
				addR_KingMoveForTPos(66, rowcolumn, chessId, depth);
			if (IsBlack(bp_all.getXY(76)))
				addR_KingMoveForTPos(76, rowcolumn, chessId, depth);
			if (IsBlack(bp_all.getXY(68)))
				addR_KingMoveForTPos(68, rowcolumn, chessId, depth);
			break;
		case 68:
			if (IsBlack(bp_all.getXY(67)))
				addR_KingMoveForTPos(67, rowcolumn, chessId, depth);
			if (IsBlack(bp_all.getXY(77)))
				addR_KingMoveForTPos(77, rowcolumn, chessId, depth);
			break;
		default:
			break;
		}

	}

	private void addMove4R_PAWN(byte rowcolumn, byte chessId, int depth) {

		int row = BitPlane.getRow(rowcolumn);
		int column = BitPlane.getColumn(rowcolumn);

		byte txy;

		if (row <= 4) {// 红兵-过河
			txy = (byte) (rowcolumn - BitPlane.width);
			if (txy > -1) {// 向上 未出边界
				if (!IsRed(bp_all.getXY(txy))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(txy);
					move.tRowColumn = (byte) txy;

				}
			}

			int tc = column - 1;
			if (tc >= 0) {// 左移
				txy = (byte) (rowcolumn - 1);
				if (!IsRed(bp_all.getXY(txy))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(txy);
					move.tRowColumn = (byte) txy;
				}
			}

			tc = column + 1;
			if (tc < BitPlane.width) {// 右移
				txy = (byte) (rowcolumn + 1);
				if (!IsRed(bp_all.getXY(txy))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(txy);
					move.tRowColumn = (byte) txy;
				}
			}

		} else {// 红兵-未过河
			txy = (byte) (rowcolumn - BitPlane.width);
			if (!IsRed(bp_all.getXY(txy))) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = bp_all.getXY(txy);
				move.tRowColumn = (byte) txy;
			}
		}

	}

	private void addMove4R_PAWN4Chked(byte rowcolumn, byte chessId, int depth) {
		int row = BitPlane.getRow(rowcolumn);
		int column = BitPlane.getColumn(rowcolumn);

		byte txy;

		if (row <= 4) {// 红兵-过河
			txy = (byte) (rowcolumn - BitPlane.width);
			if (txy > -1) {// 向上 未出边界
				if (!IsRed(bp_all.getXY(txy))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(txy);
					move.tRowColumn = (byte) txy;

					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);

				}
			}

			int tc = column - 1;
			if (tc >= 0) {// 左移
				txy = (byte) (rowcolumn - 1);
				if (!IsRed(bp_all.getXY(txy))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(txy);
					move.tRowColumn = (byte) txy;

					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);
				}
			}

			tc = column + 1;
			if (tc < BitPlane.width) {// 右移
				txy = (byte) (rowcolumn + 1);
				if (!IsRed(bp_all.getXY(txy))) {
					ChessMove move = this.m_MoveList[depth][movepos];

					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(txy);
					move.tRowColumn = (byte) txy;

					this.makeMove(move);
					if (!this.isRedKingAttacked()) {
						movepos++;
					}
					this.unMakeMove(move);
				}
			}

		} else {// 红兵-未过河
			txy = (byte) (rowcolumn - BitPlane.width);
			if (!IsRed(bp_all.getXY(txy))) {
				ChessMove move = this.m_MoveList[depth][movepos];

				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = bp_all.getXY(txy);
				move.tRowColumn = (byte) txy;

				this.makeMove(move);
				if (!this.isRedKingAttacked()) {
					movepos++;
				}
				this.unMakeMove(move);
			}
		}

	}

	private void addMove4R_PAWNAttacking(byte rowcolumn, byte chessId, int depth) {
		int row = BitPlane.getRow(rowcolumn);
		int column = BitPlane.getColumn(rowcolumn);

		byte txy;

		if (row <= 4) {// 红兵-过河
			txy = (byte) (rowcolumn - BitPlane.width);
			if (txy > -1) {// 向上 未出边界
				if (IsBlack(bp_all.getXY(txy))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(txy);
					move.tRowColumn = (byte) txy;

				}
			}

			int tc = column - 1;
			if (tc >= 0) {// 左移
				txy = (byte) (rowcolumn - 1);
				if (IsBlack(bp_all.getXY(txy))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(txy);
					move.tRowColumn = (byte) txy;
				}
			}

			tc = column + 1;
			if (tc < BitPlane.width) {// 右移
				txy = (byte) (rowcolumn + 1);
				if (IsBlack(bp_all.getXY(txy))) {
					ChessMove move = this.m_MoveList[depth][movepos];
					movepos++;
					move.fChessId = chessId;
					move.fRowColumn = rowcolumn;
					move.tChessId = bp_all.getXY(txy);
					move.tRowColumn = (byte) txy;
				}
			}

		} else {// 红兵-未过河
			txy = (byte) (rowcolumn - BitPlane.width);
			if (IsBlack(bp_all.getXY(txy))) {
				ChessMove move = this.m_MoveList[depth][movepos];
				movepos++;
				move.fChessId = chessId;
				move.fRowColumn = rowcolumn;
				move.tChessId = bp_all.getXY(txy);
				move.tRowColumn = (byte) txy;
			}
		}
	}

	private void addMoves4AttackingChessId(ChessMove[][] moveList2,
			byte rowcolumn, byte chessId, int depth) {
		switch (chessId) {
		case R_CAR:
			addMove4R_CARAttacking(rowcolumn, chessId, depth);
			break;
		case R_CANON:
			addMove4R_CANONAttacking(rowcolumn, chessId, depth);
			break;
		case R_HORSE:
			addMove4R_HORSEAttacking(rowcolumn, chessId, depth);
			break;
		case R_BISHOP:
			addMove4R_BISHOPAttacking(rowcolumn, chessId, depth);
			break;
		case R_ELEPHANT:
			addMove4R_ELEPHANTAttacking(rowcolumn, chessId, depth);
			break;
		case R_KING:
			addMove4R_KINGAttacking(rowcolumn, chessId, depth);
			break;
		case R_PAWN:
			addMove4R_PAWNAttacking(rowcolumn, chessId, depth);
			break;

		// /////////////////////////
		case B_CANON:
			addMove4B_CANON4Attacking(rowcolumn, chessId, depth);
			break;

		case B_HORSE:
			addMove4B_HORSE4Attacking(rowcolumn, chessId, depth);
			break;

		case B_CAR:
			addMove4B_CAR4Attacking(rowcolumn, chessId, depth);
			break;

		case B_BISHOP:
			addMove4B_BISHOP4Attacking(rowcolumn, chessId, depth);
			break;

		case B_ELEPHANT:
			addMove4B_ELEPHANT4Attacking(rowcolumn, chessId, depth);
			break;

		case B_KING:
			addMove4B_KINGAttacking(rowcolumn, chessId, depth);
			break;

		case B_PAWN:
			addMove4B_PAWNAttacking(rowcolumn, chessId, depth);
			break;

		default:
			break;
		}

	}

	public void addMoves4ChessId(ChessMove[][] movelist, final byte rowcolumn,
			byte chessId, int depth) {

		switch (chessId) {
		case R_CAR:
			addMove4R_CAR(rowcolumn, chessId, depth);
			break;
		case R_CANON:
			addMove4R_CANON(rowcolumn, chessId, depth);
			break;
		case R_HORSE:
			addMove4R_HORSE(rowcolumn, chessId, depth);
			break;
		case R_BISHOP:
			addMove4R_BISHOP(rowcolumn, chessId, depth);
			break;
		case R_ELEPHANT:
			addMove4R_ELEPHANT(rowcolumn, chessId, depth);
			break;
		case R_KING:
			addMove4R_KING(rowcolumn, chessId, depth);
			break;
		case R_PAWN:
			addMove4R_PAWN(rowcolumn, chessId, depth);
			break;

		// /////////////////////////
		case B_CANON:
			addMove4B_CANON(rowcolumn, chessId, depth);
			break;

		case B_HORSE:
			addMove4B_HORSE(rowcolumn, chessId, depth);
			break;

		case B_CAR:
			addMove4B_CAR(rowcolumn, chessId, depth);
			break;

		case B_BISHOP:
			addMove4B_BISHOP(rowcolumn, chessId, depth);
			break;

		case B_ELEPHANT:
			addMove4B_ELEPHANT(rowcolumn, chessId, depth);
			break;

		case B_KING:
			addMove4B_KING(rowcolumn, chessId, depth);
			break;

		case B_PAWN:
			addMove4B_PAWN(rowcolumn, chessId, depth);
			break;

		default:
			break;
		}
	}

	private void addMoves4ChkedForChessId(ChessMove[][] movelist,
			final byte rowcolumn, byte chessId, int depth) {
		boolean chktest = true;

		switch (chessId) {
		case R_CAR:
			addMove4R_CAR4Chked(rowcolumn, chessId, depth);
			break;
		case R_CANON:
			addMove4R_CANON4Chked(rowcolumn, chessId, depth);
			break;
		case R_HORSE:
			addMove4R_HORSE4Chked(rowcolumn, chessId, depth);
			break;
		case R_BISHOP:
			addMove4R_BISHOP4Chked(rowcolumn, chessId, depth);
			break;
		case R_ELEPHANT:
			addMove4R_ELEPHANT4Chked(rowcolumn, chessId, depth);
			break;
		case R_KING:
			addMove4R_KING4Chked(rowcolumn, chessId, depth);
			break;
		case R_PAWN:
			addMove4R_PAWN4Chked(rowcolumn, chessId, depth);
			break;

		// /////////////////////////
		case B_CANON:
			addMove4B_CANON4Chked(rowcolumn, chessId, depth);
			break;

		case B_HORSE:
			addMove4B_HORSE4Chked(rowcolumn, chessId, depth);
			break;

		case B_CAR:
			addMove4B_CAR4Chked(rowcolumn, chessId, depth);
			break;

		case B_BISHOP:
			addMove4B_BISHOP4Chked(rowcolumn, chessId, depth);
			break;

		case B_ELEPHANT:
			addMove4B_ELEPHANT4Chked(rowcolumn, chessId, depth);
			break;

		case B_KING:
			addMove4B_KING4Chked(rowcolumn, chessId, depth);
			break;

		case B_PAWN:
			addMove4B_PAWN4Chked(rowcolumn, chessId, depth);
			break;

		default:
			break;
		}

	}

	private void addR_KingMoveForTPos(int txy, byte rowcolumn, byte chessId,
			int depth) {
		final byte tchess = bp_all.getXY(txy);
		if (!IsRed(tchess)) {
			ChessMove move = this.m_MoveList[depth][movepos];
			movepos++;
			move.fChessId = chessId;
			move.fRowColumn = rowcolumn;
			move.tChessId = tchess;
			move.tRowColumn = (byte) txy;
		}
	}

	private void addR_KingMoveForTPos4Chked(int txy, byte rowcolumn,
			byte chessId, int depth) {

		final byte tchess = bp_all.getXY(txy);
		if (!IsRed(tchess)) {
			ChessMove move = this.m_MoveList[depth][movepos];
			move.fChessId = chessId;
			move.fRowColumn = rowcolumn;
			move.tChessId = tchess;
			move.tRowColumn = (byte) txy;

			this.makeMove(move);
			if (!this.isRedKingAttacked()) {
				movepos++;
			}
			this.unMakeMove(move);
		}

	}

	public ChessBoardBitPlanes copy() throws CloneNotSupportedException {

		ChessBoardBitPlanes result = new ChessBoardBitPlanes();
		result.bp_all = this.bp_all.Copy();

		result.b_king_pos = this.b_king_pos;
		result.r_king_pos = this.r_king_pos;

		// 似乎不需要这些
		result.movelist = new ArrayList<ChessMove>(200);
		result.movelist.addAll(this.movelist);
		result.lastMove = this.lastMove;
		result.movepos = this.movepos;

		return result;
	}

	public int generatePossibleAttackingMoves(boolean isred, int depth) {
		movepos = 0;

		if (isred) {
			for (byte xy = 0; xy < BitPlane.MAX; xy++) {
				final byte xyChessId = bp_all.getXY(xy);
				if (IsRed(xyChessId)) {
					addMoves4AttackingChessId(this.m_MoveList, xy, xyChessId,
							depth);
				}
			}

		} else {
			for (byte xy = 0; xy < BitPlane.MAX; xy++) {
				final byte xyChessId = bp_all.getXY(xy);
				if (IsBlack(xyChessId)) {
					addMoves4AttackingChessId(this.m_MoveList, xy, xyChessId,
							depth);
				}
			}
		}
		return movepos;

	}

	public int generatePossibleChkedMoves(boolean isred, int depth) {
		movepos = 0;
		if (isred) {
			for (byte xy = 0; xy < BitPlane.MAX; xy++) {
				final byte xyChessId = bp_all.getXY(xy);
				if (IsRed(xyChessId)) {
					addMoves4ChkedForChessId(this.m_MoveList, xy, xyChessId,
							depth);
				}
			}

		} else {
			for (byte xy = 0; xy < BitPlane.MAX; xy++) {
				final byte xyChessId = bp_all.getXY(xy);
				if (IsBlack(xyChessId)) {
					addMoves4ChkedForChessId(this.m_MoveList, xy, xyChessId,
							depth);
				}
			}
		}
		return movepos;
	}

	public int generatePossibleMoves(boolean isred, int depth) {

		movepos = 0;

		if (isred) {
			for (byte xy = 0; xy < BitPlane.MAX; xy++) {
				final byte xyChessId = bp_all.getXY(xy);
				if (IsRed(xyChessId)) {
					addMoves4ChessId(this.m_MoveList, xy, xyChessId, depth);
				}
			}

		} else {
			for (byte xy = 0; xy < BitPlane.MAX; xy++) {
				final byte xyChessId = bp_all.getXY(xy);
				if (IsBlack(xyChessId)) {
					addMoves4ChessId(this.m_MoveList, xy, xyChessId, depth);
				}
			}
		}
		return movepos;
	}

	public List<ChessMove> getAvailableMoves(byte rowColumn) {
		byte chessid = this.bp_all.getXY(rowColumn);
		this.movepos = 0;
		this.addMoves4ChessId(m_MoveList, rowColumn, chessid, 0);
		ArrayList<ChessMove> result = new ArrayList<ChessMove>();
		result.addAll(Arrays.asList(m_MoveList[0]).subList(0, movepos));
		return result;
	}

	public byte getXY(byte xy) {
		return bp_all.bitArray[xy];
	}

	public byte getXY(int row, int column) {
		return bp_all.bitArray[row * BitPlane.width + column];
	}

	public boolean isAttacking(byte id, byte cor, byte xid, byte attckedCor) {

		if (cor == attckedCor || cor < 0 || cor > 89 || attckedCor < 0
				|| attckedCor > 89) {
			return false;
		}

		// if (IsSameSide(chessIdAttcking, chessIdAttcked)) return false;
		// 保证了的条件 不需要这里测试
		/*
		 * if (((id & 0xF) > 0 && (xid & 0xF) > 0) || ((id & 0xF0) > 0 && (xid &
		 * 0xF0) > 0)) return false;
		 */

		byte frow = (byte) (cor / BitPlane.width);
		byte fcolumn = (byte) (cor % BitPlane.width);

		byte trow = (byte) (attckedCor / BitPlane.width);
		byte tcolumn = (byte) (attckedCor % BitPlane.width);

		int columndiff = fcolumn - tcolumn;
		int rowdiff = frow - trow;

		boolean result = false;

		switch (id) {

		case B_KING:
		case R_KING:
			result = ((Math.abs(frow - trow) + Math.abs(fcolumn - tcolumn)) == 1);
			break;
		case B_CAR:
		case R_CAR:
			if (fcolumn == tcolumn) {
				byte min = (byte) Math.min(frow, trow);
				byte max = (byte) Math.max(frow, trow);
				int tmp = 0;
				for (byte y = min; y < max; y++) {
					tmp += bp_all.getXY(y, fcolumn) == 0 ? 0 : 1;
					if (tmp >= 2)
						break;
				}
				result = tmp < 2;
			} else if (frow == trow) {
				byte min = (byte) Math.min(fcolumn, tcolumn);
				byte max = (byte) Math.max(fcolumn, tcolumn);
				int tmp = 0;
				for (byte x = min; x < max; x++) {
					tmp += bp_all.getXY(frow, x) == 0 ? 0 : 1;
					if (tmp >= 2)
						break;
				}
				result = tmp < 2;
			} else {
				result = false;
			}
			break;
		case B_HORSE:
		case R_HORSE:

			// FIXME 换行似乎没有处理
			switch (columndiff) {
			case 2:
				switch (rowdiff) {
				case 1:
				case -1:
					result = bp_all.getXY(frow, (byte) (fcolumn - 1)) == 0;
					break;
				default:
					result = false;
				}

				break;
			case 1:
				switch (rowdiff) {
				case 2:
					result = bp_all.getXY((byte) (frow - 1), fcolumn) == 0;
					break;
				case -2:
					result = bp_all.getXY((byte) (frow + 1), fcolumn) == 0;
					break;
				default:
					result = false;
				}

				break;
			case -1:
				switch (rowdiff) {
				case 2:
					result = bp_all.getXY((byte) (frow - 1), fcolumn) == 0;
					break;
				case -2:
					result = bp_all.getXY((byte) (frow + 1), fcolumn) == 0;
					break;
				default:
					result = false;
				}

				break;
			case -2:
				switch (rowdiff) {
				case 1:
				case -1:
					result = bp_all.getXY(frow, (byte) (fcolumn + 1)) == 0;
					break;
				default:
					result = false;
				}

				break;
			default:
				result = false;
			}
			break;

		case B_CANON:
		case R_CANON:
			if (columndiff == 0) {
				byte min = (byte) Math.min(frow, trow);
				byte max = (byte) Math.max(frow, trow);

				int tmp = 0;
				for (byte y = min; y < max; y++) {
					tmp += bp_all.getXY(y, fcolumn) == 0 ? 0 : 1;
					if (tmp > 2)
						break;
				}
				result = (tmp == 2);
			} else if (rowdiff == 0) {
				byte min = (byte) Math.min(fcolumn, tcolumn);
				byte max = (byte) Math.max(fcolumn, tcolumn);
				int tmp = 0;
				for (byte x = min; x < max; x++) {
					tmp += bp_all.getXY(frow, x) == 0 ? 0 : 1;
					if (tmp > 2)
						break;
				}
				result = (tmp == 2);
			} else {
				result = false;
			}
			break;

		case R_BISHOP:
			// 9-3 9-5 8-4 7-3 7-5
			switch (cor) {
			case 84:// 9*9+3
				result = attckedCor == 76;
				break;
			case 86:// 9*9+5
				result = attckedCor == 76;
				break;
			case 76:// 8*9+4
				result = (attckedCor == 84 || attckedCor == 86
						|| attckedCor == 66 || attckedCor == 68);
				break;
			case 66:// 7*9+3
				result = attckedCor == 76;
				break;
			case 68:// 7*9+5
				result = attckedCor == 76;
				break;
			default:
				break;
			}
			break;

		case B_BISHOP:
			// 0-3 0-5 1-4 2-3 2-5
			switch (cor) {
			case 3:// 0*9+3
				result = attckedCor == 13;
				break;
			case 5:// 0*9+5
				result = attckedCor == 13;
				break;
			case 13:// 1*9+4
				result = (attckedCor == 3 || attckedCor == 5
						|| attckedCor == 21 || attckedCor == 23);
				break;
			case 21:// 2*9+3
				result = attckedCor == 13;
				break;
			case 23:// 2*9+5
				result = attckedCor == 13;
				break;
			default:
				break;
			}
			break;

		case B_ELEPHANT:
			// 0-2 0-6 2-0 2-4 2-8 4-2 4-6
			switch (cor) {
			case 2:// 0*9+2
				result = (attckedCor == 18 && bp_all.getXY(10) == 0 || attckedCor == 22
						&& bp_all.getXY(12) == 0);
				break;
			case 6:// 0*9+6
				result = (attckedCor == 22 && bp_all.getXY(14) == 0 || attckedCor == 26
						&& bp_all.getXY(16) == 0);
				break;
			case 18:// 2*9+0
				result = (attckedCor == 2 && bp_all.getXY(10) == 0 || attckedCor == 38
						&& bp_all.getXY(28) == 0);
				break;
			case 22:// 2*9+4
				result = (attckedCor == 2 && bp_all.getXY(12) == 0
						|| attckedCor == 6 && bp_all.getXY(14) == 0
						|| attckedCor == 38 && bp_all.getXY(30) == 0 || attckedCor == 42
						&& bp_all.getXY(32) == 0);
				break;
			case 26:// 2*9+8
				result = (attckedCor == 6 && bp_all.getXY(16) == 0 || attckedCor == 42
						&& bp_all.getXY(34) == 0);
				break;
			case 38:// 4*9+2
				result = (attckedCor == 18 && bp_all.getXY(28) == 0 || attckedCor == 22
						&& bp_all.getXY(30) == 0);
				break;
			case 42:// 4*9+6
				result = (attckedCor == 18 && bp_all.getXY(30) == 0 || attckedCor == 26
						&& bp_all.getXY(34) == 0);
				break;
			default:
				break;
			}

			break;

		case R_ELEPHANT:
			// 9-2 9-6 7-0 7-4 7-8 5-2 5-6
			// another way
			result = Math.abs(rowdiff) == 2 && Math.abs(columndiff) == 2
					&& bp_all.getXY((attckedCor + cor) / 2) == 0;
			break;

		case B_PAWN:
			if (frow > 4) {
				result = Math.abs(columndiff) + Math.abs(rowdiff) == 1;
			} else {
				result = (columndiff == 0 && rowdiff == -1);
			}
			break;
		case R_PAWN:
			if (frow <= 4) {
				result = Math.abs(columndiff) + Math.abs(rowdiff) == 1;
			} else {
				result = (columndiff == 0 && rowdiff == 1);
			}
			break;
		default:
			break;
		}

		return result;
	}

	public boolean isBlackKingAttacked() {
		byte txy = this.b_king_pos;

		for (byte xy = 0; xy < 90; xy++) {
			final byte fid = getXY(xy);
			if (IsRed(fid) /* && fid != B_KING */) {
				if (isAttacking(fid, xy, B_KING, txy)) {
					return true;
				}
			}
		}
		return false;
	}

	/**
	 * 第25条 棋例释义
	 * 
	 * 
	 * 25.1 对局中有时出现双方着法循环不变的重复局面。据以裁处这种局面的规则条例，称为“棋例”。
	 * 
	 * 25.2 长将、长杀、长捉、一将一杀、一将一捉、一杀一捉等循环重复的攻击手段，统称为“禁止着法”。
	 * 闲着（含：兑、献、拦、跟）、数将一闲、数杀一闲、数捉一闲等着法，无论是否重复，统称为“允许着法”。
	 * 
	 * 25.3 车、马、炮、过河兵（卒）、士、相（象），均算“子力”。帅(将)、未过河兵（卒），不算“子力”。“子力”简称“子”。
	 * 子力价值是衡量子力得失的尺度，也是判断是否 “捉子”的依据之一。 原则上，一车相当于双马、双炮或一马一炮；马炮相等；士相（象）相等；
	 * 过河兵（卒）价值浮动，一兵换取数子或一子换取数兵均不算得子。
	 * 
	 * 
	 * 第26条 棋例总则
	 * 
	 * 26.1 在任何情况下，均不允许单方面长将。
	 * 
	 * 26.2 双方均为允许着法，双方不变作和。
	 * 
	 * 26.3 双方均为禁止着法（不包括一方为长将），双方不变作和。
	 * 
	 * 26.4 一方为禁止着法，另一方为允许着法，应由前者变着，不变判负。
	 * 
	 * 第27条 棋例通则
	 * 
	 * 27.1 允许帅(将)本身步步叫吃对方的棋子，按闲着处理. 其他棋子和帅(将)同时捉吃或借帅(将)之力捉吃对方的棋子,均按捉处理.
	 * 
	 * 27.2 兵(卒)本身捉吃对方的棋子(不含将.杀),按闲处理;如形成相互长打局面,则应按捉处理.
	 * 
	 * 27.3 占据防守要点,立即构成简明和棋,附带产生的捉士相(象),按闲处理.
	 * 
	 * 27.4 凡走子兼具多种作用时,应从重称呼和裁处.如杀兼捉,按杀;捉兼况,按捉等,依此类推.
	 * 
	 * 第28条　术语解释 　 　　
	 * 
	 * 28.1　将 　　凡走子直接攻击对方帅(将)者，称为“照将”，简称“将”。 　　
	 * 
	 * 28.2　杀　　凡走子企图在下一着照将或连续照将，将死对方者，称为“杀着”，简称“杀”。 　　
	 * 
	 * 28.3　捉　　凡走子后能够造成在下一着(包括从下一着开始运用连续照将或连续交换的手段)吃掉对方某个无根子，称为“捉”。 　　
	 * 
	 * 28.4　打 　　将、杀、捉等攻击手段，统称为“打”。 　　
	 * 
	 * 28.5　兑 　　凡走子可与同等子力互换吃去者，称为“邀兑”，简称“兑”。 　　
	 * 
	 * 28.6　献 　　凡无根子送吃，而对方同兵种子一旦吃掉此子后，不致立即被将死或立即在子力价值上遭受损失者，称为“献”。 　　
	 * 
	 * 28.7　拦 　　凡走子阻拦对方棋子的活动，而又不具攻击作用者，称为“拦”。 　　
	 * 
	 * 28.8　跟 　　凡走子盯牵对方有根子，而又不具攻击作用者，称为“跟”。
	 * 
	 * 28.9　闲 　　凡走子性质不属于将、杀、捉，统称为“闲”。兑、献、拦、跟，均属“闲”的范畴。 　　
	 * 
	 * 28.10　长将 凡走子连续不停照将，而形成循环者，称为“长将”。 　　
	 * 
	 * 28.11　长杀 　　凡走子连续不停杀着，而形成循环者，称为“长杀”。
	 * 
	 * 28.12　长捉 　　凡走子连续追捉一子或数子，而形成循环者，称为“长捉”。 　　
	 * 
	 * 28.13　长兑 　　凡走子连续不停邀兑，称为“长兑”。 　　类似解释也适用于“长献”、“长拦”、“长跟”。 　　
	 * 
	 * 28.14　长打对长打 　　凡双方走子循环反复，步步是打，称为“长打对长打”。 　　
	 * 
	 * 28.15　长打对非长打 　　双方走子循环反复，一方步步是打，中间没有闲着，另一方中间有闲着，则称为“长打对非长打”。 　　
	 * 
	 * 28.16　有根子和无根子 　　凡有己方其他棋子(包括暗根)充分保护的子，称为“有根子”；反之，称为“无根子”。
	 * 　　形式上是根，实际上起不到充分保护作用，称为假根或少根、假根子和少根子按无根子处理。 　
	 * 
	 * 第29条　“捉”的概念 　 　　构成“捉子”，应符合下列条件：
	 * 
	 * 29.1　捉子的形式可以有：能够直接吃子；能够通过连续照将吃子；能够通过完整的交换过程得子。 　
	 * 
	 * 29.2　“捉”产生于刚走的这着棋，上一着尚不存在。 　　
	 * 
	 * 29.3　直接或间接被捉的，是有子力价值的无根子(含：假根子、少根子)。
	 * 
	 * 29.4　下一着吃子或得子后，不致被将死。
	 * 
	 * @param move
	 * @param depth
	 * @return
	 */
	public boolean isLooping(ChessMove move, int depth) {
		if (this.movelist.size() < 4) {
			return false;
		}

		ChessMove first = this.movelist.get(this.movelist.size() - 4);
		ChessMove second = this.movelist.get(this.movelist.size() - 3);
		ChessMove third = this.movelist.get(this.movelist.size() - 2);
		ChessMove fourth = this.movelist.get(this.movelist.size() - 1);
		ChessMove fifth = move;

		if (first.chk && third.chk && fifth.chk) {
			if (first.fChessId == third.fChessId
					&& first.fChessId == fifth.fChessId) {
				return true;
			}
		}
		return false;
	}

	public boolean isRedKingAttacked() {
		byte txy = this.r_king_pos;
		for (byte xy = 0; xy < 90; xy++) {
			final byte fid = getXY(xy);
			if (IsBlack(fid) /* && fid != B_KING */) {
				if (isAttacking(fid, xy, R_KING, txy)) {
					return true;
				}
			}
		}
		return false;
	}

	public void makeMove(ChessMove possibleMove) {
		makeMove(possibleMove, false);
	}

	public void makeMove(ChessMove possibleMove, boolean updatestatus) {
		ChessMove pm = possibleMove;
		byte fid = pm.fChessId;
		byte frc = pm.fRowColumn;

		byte tid = pm.tChessId;
		byte trc = pm.tRowColumn;

		bp_all.bitArray[frc] = NOCHESS;
		bp_all.bitArray[trc] = fid;

		BitPlane x = cibp.get(fid);
		x.removeKey(frc);
		x.putKey(trc, ChessBoardBitPlanes.Byte1);

		if (fid == R_KING) {
			this.r_king_pos = trc;
		} else if (fid == B_KING) {
			this.b_king_pos = trc;
		}

		BitPlane t = cibp.get(tid);
		if (t != null) {
			t.removeKey(trc);
		}

		if (tid == R_KING) {
			this.r_king_pos = -1;
		} else if (tid == B_KING) {
			this.b_king_pos = -1;
		}

		this.lastMove = possibleMove;
		this.movelist.add(pm);

		if (updatestatus) {
			updateMoveChkStatus(this.lastMove);
		}

	}

	public void unMakeMove(ChessMove possibleMove) {
		ChessMove pm = possibleMove;
		byte fid = pm.fChessId;
		byte frc = pm.fRowColumn;

		byte tid = pm.tChessId;
		byte trc = pm.tRowColumn;

		bp_all.bitArray[frc] = fid;
		bp_all.bitArray[trc] = tid;

		BitPlane x = cibp.get(fid);
		x.removeKey(trc);
		x.putKey(frc, ChessBoardBitPlanes.Byte1);

		if (fid == R_KING) {
			this.r_king_pos = frc;
		} else if (fid == B_KING) {
			this.b_king_pos = frc;
		}

		BitPlane t = cibp.get(tid);
		if (t != null) {
			t.putKey(trc, ChessBoardBitPlanes.Byte1);
		}
		if (tid == R_KING) {
			this.r_king_pos = trc;
		} else if (tid == B_KING) {
			this.b_king_pos = trc;
		}

		int csize = this.movelist.size();
		this.movelist.remove(csize - 1);

		if (csize >= 2) {
			this.lastMove = this.movelist.get(csize - 2);
		} else {
			this.lastMove = null;
		}
	}

	private void updateMoveChkStatus(ChessMove move) {
		boolean red = IsRed(move.fChessId);
		if (red) {
			for (byte xy = 0; xy < 90; xy++) {
				final byte chess = bp_all.getXY(xy);
				if (IsRed(chess)) {
					switch (chess) {
					case R_CAR:
						if (isAttacking(chess, xy, B_KING, this.b_king_pos)) {
							move.chk = true;
							return;
						}
						break;
					case R_HORSE:
						if (isAttacking(chess, xy, B_KING, this.b_king_pos)) {
							move.chk = true;
							return;
						}
						break;
					case R_CANON:
						if (isAttacking(chess, xy, B_KING, this.b_king_pos)) {
							move.chk = true;
							return;
						}

						break;
					case R_PAWN:
						if (isAttacking(chess, xy, B_KING, this.b_king_pos)) {
							move.chk = true;
							return;
						}
						break;
					default:
						break;
					}
				}
			}
		} else {
			for (byte xy = 0; xy < 90; xy++) {
				final byte chess = bp_all.getXY(xy);
				if (IsBlack(chess)) {
					switch (chess) {
					case B_CAR:
						if (isAttacking(chess, xy, R_KING, this.r_king_pos)) {
							move.chk = true;
							return;
						}
						break;
					case B_HORSE:
						if (isAttacking(chess, xy, R_KING, this.r_king_pos)) {
							move.chk = true;
							return;
						}
						break;
					case B_CANON:
						if (isAttacking(chess, xy, R_KING, this.r_king_pos)) {
							move.chk = true;
							return;
						}

						break;
					case B_PAWN:
						if (isAttacking(chess, xy, R_KING, this.r_king_pos)) {
							move.chk = true;
							return;
						}
						break;
					default:
						break;
					}
				}
			}
		}
	}

}
